/* ChaosWizard.com RPG Worlds — dark woodland / earthen theme */

:root {
  --cw-bg: #0a0806;
  --cw-bg-elevated: #100e0a;
  --cw-panel: #12100c;
  --cw-panel-2: #16130f;
  --cw-border: #2a241c;
  --cw-gold: #d4a84b;
  --cw-gold-dim: #8a6a2e;
  --cw-copper: #c47a4a;
  --cw-parchment: #ebe2cc;
  --cw-parchment-dim: #c4b59a;
  --cw-ink: #100c08;
  --cw-text: #f2ebe3;
  --cw-muted: #b5a894;
  --cw-danger: #d45c5c;
  --cw-success: #5cba8a;
  --cw-info: #6a9fd4;
  --cw-engine: #c4a574;  /* bark/amber, not violet */
  --cw-dice: #e0b84a;
  --cw-player: #7ec8a3;
  --cw-radius: 12px;
  --cw-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
  --cw-glow: 0 0 24px rgba(212, 168, 75, 0.12);
  --cw-paper: #b8ab8c;
  --cw-paper-deep: #9a8b6e;
  --cw-paper-edge: #8a7048;
  --cw-paper-ink: #2a1c10;
  --cw-leather: #1a1410;
  --cw-tooling: rgba(212, 168, 75, 0.35);
  --cw-fiber:
    repeating-linear-gradient(
      92deg,
      transparent 0 11px,
      rgba(90, 60, 20, 0.035) 11px 12px
    ),
    repeating-linear-gradient(
      8deg,
      transparent 0 17px,
      rgba(140, 100, 40, 0.03) 17px 18px
    );
  /* Shared modal surface — warm ink only (no cool purple shells) */
  --cw-modal-surface: linear-gradient(
    165deg,
    var(--cw-panel-2) 0%,
    var(--cw-panel) 45%,
    var(--cw-bg-elevated) 100%
  );
  --cw-modal-overlay: rgba(6, 4, 2, 0.82);
  --cw-modal-inset: rgba(0, 0, 0, 0.28);
  /* Base type; mobile/device multiplies by 1.07 for readability */
  --cw-font-size: 15px;
  --cw-font-size-mobile: calc(var(--cw-font-size) * 1.07);
  --font-display: "Cinzel", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  --font-body: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  /* Avoid horizontal bounce / overflow on mobile browsers */
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html,
body {
  margin: 0;
  height: 100%;
  /* dvh accounts for mobile browser chrome (Safari/Chrome) */
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--cw-bg);
  color: var(--cw-text);
  font-family: var(--font-body);
  font-size: var(--cw-font-size);
  line-height: 1.5;
}

body {
  background-color: var(--cw-bg);
  background-image:
    radial-gradient(ellipse 70% 42% at 18% 0%, rgba(120, 78, 28, 0.28), transparent 58%),
    radial-gradient(ellipse 55% 38% at 92% 100%, rgba(28, 48, 22, 0.16), transparent 52%),
    radial-gradient(ellipse 40% 30% at 70% 20%, rgba(212, 168, 75, 0.05), transparent 60%),
    linear-gradient(180deg, #0e0b08 0%, #090806 100%);
  min-height: 100vh;
  min-height: 100dvh;
  /* iOS safe areas (notch / home indicator) */
  padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0)
    env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0);
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

input,
textarea,
select {
  /* Prevent iOS Safari zoom-on-focus (needs ≥16px on form fields) */
  font-size: 16px;
  border-radius: 8px;
  -webkit-appearance: none;
  appearance: none;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

a {
  color: var(--cw-gold);
}

/* —— App shell —— */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  overflow: hidden;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 1rem;
  padding-left: max(1rem, env(safe-area-inset-left, 0px));
  padding-right: max(1rem, env(safe-area-inset-right, 0px));
  background:
    linear-gradient(180deg, rgba(212, 168, 75, 0.08), transparent 42%),
    linear-gradient(180deg, #1a1510 0%, #100d0a 100%);
  border-bottom: 1px solid rgba(212, 168, 75, 0.22);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35), inset 0 -1px 0 rgba(212, 168, 75, 0.08);
  z-index: 20;
  flex-shrink: 0;
  min-width: 0;
}

/*
 * Combat mode: hide site header so the two-column play board (sheet | dialog)
 * can use full viewport height. Restored automatically in exploration.
 */
body.cw-combat-mode .topbar {
  display: none !important;
}
body.cw-combat-mode .topbar + .gold-rule {
  display: none !important;
}
body.cw-combat-mode #play.play {
  flex: 1 1 auto;
  min-height: 0;
  max-height: 100dvh;
}
body.cw-combat-mode .dm-pane .log-scroll {
  /* Give narrative/dialog a bit more room once the header is gone */
  flex: 1 1 auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-mark {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  display: block;
  overflow: hidden;
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.brand-text h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--cw-gold);
  text-transform: uppercase;
  line-height: 1.15;
}

.brand-text p {
  margin: 0.1rem 0 0;
  font-size: 0.72rem;
  color: var(--cw-muted);
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.8rem;
  color: var(--cw-muted);
  flex-wrap: wrap;
  justify-content: flex-end;
}

.topbar-meta strong {
  color: var(--cw-parchment-dim);
  font-weight: 600;
}

.topbar-meta .model-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  max-width: min(42vw, 22rem);
}

.topbar-meta .model-chip .model-prefix {
  color: var(--cw-muted);
  flex-shrink: 0;
}

button.model-link {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--cw-gold);
  font: inherit;
  font-weight: 600;
  padding: 0.15rem 0.35rem;
  margin: 0;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
  text-decoration: underline;
  text-decoration-color: rgba(212, 168, 75, 0.45);
  text-underline-offset: 0.18em;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color 0.15s ease, background 0.15s ease, text-decoration-color 0.15s ease;
}

button.model-link:hover,
button.model-link:focus-visible {
  color: var(--cw-parchment);
  background: rgba(212, 168, 75, 0.12);
  text-decoration-color: var(--cw-gold);
  outline: none;
}

button.tokens-btn {
  appearance: none;
  flex-shrink: 0;
  padding: 0.18rem 0.5rem;
  border-radius: 6px;
  border: 1px solid rgba(140, 160, 200, 0.4);
  background: rgba(100, 130, 180, 0.12);
  color: #6e7886;
  font-family: var(--font-display);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

/* Tokens + Model chrome: admin only (hub and play) */
body:not(.cw-admin) .tokens-btn,
body:not(.cw-admin) .model-link,
body:not(.cw-admin) .admin-only-chrome,
body:not(.cw-admin) #tokensBackdrop,
body:not(.cw-admin) #modelBackdrop {
  display: none !important;
}

button.tokens-btn:hover,
button.tokens-btn:focus-visible {
  background: rgba(120, 150, 200, 0.22);
  border-color: #9ab0d0;
  color: var(--cw-parchment);
  outline: none;
}

button.questlog-btn {
  appearance: none;
  flex-shrink: 0;
  margin-left: 0.15rem;
  padding: 0.18rem 0.5rem;
  border-radius: 6px;
  border: 1px solid rgba(212, 168, 75, 0.4);
  background: rgba(212, 168, 75, 0.1);
  color: var(--cw-gold);
  font-family: var(--font-display);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

button.questlog-btn:hover:not(:disabled),
button.questlog-btn:focus-visible:not(:disabled) {
  background: rgba(212, 168, 75, 0.2);
  border-color: var(--cw-gold);
  color: var(--cw-parchment);
  outline: none;
}

button.questlog-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  filter: grayscale(0.85);
  pointer-events: none;
}

button.exit-btn {
  appearance: none;
  flex-shrink: 0;
  margin-left: 0.15rem;
  padding: 0.18rem 0.5rem;
  border-radius: 6px;
  border: 1px solid rgba(212, 92, 92, 0.45);
  background: rgba(212, 92, 92, 0.1);
  color: #e8a0a0;
  font-family: var(--font-display);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

button.exit-btn:hover,
button.exit-btn:focus-visible {
  background: rgba(212, 92, 92, 0.22);
  border-color: var(--cw-danger);
  color: #997d7d;
  outline: none;
}

button.exit-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.9);
  border-color: rgba(70, 58, 42, 0.5);
  background: rgba(28, 24, 18, 0.55);
  color: #5c564c;
  pointer-events: none;
}

button.exit-btn.combat-disabled {
  opacity: 0.4;
  cursor: not-allowed;
  filter: grayscale(1);
  border-color: rgba(62, 52, 38, 0.45);
  background: rgba(26, 22, 16, 0.5);
  color: #5a5248;
  pointer-events: none;
}

.topbar-meta .exit-farewell {
  color: var(--cw-gold);
  font-size: 0.82rem;
  max-width: min(70vw, 28rem);
  text-align: right;
}

body.exiting {
  cursor: wait;
}

body.exiting #play,
body.exiting #hub {
  opacity: 0.55;
  pointer-events: none;
}

.gold-rule {
  height: 3px;
  background:
    linear-gradient(
      90deg,
      transparent,
      var(--cw-gold-dim) 12%,
      var(--cw-gold) 50%,
      var(--cw-gold-dim) 88%,
      transparent
    );
  opacity: 0.85;
  position: relative;
  flex-shrink: 0;
}

.gold-rule::before,
.gold-rule::after {
  content: "✦";
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  color: var(--cw-gold);
  font-size: 0.55rem;
  opacity: 0.7;
  line-height: 1;
  pointer-events: none;
}

.gold-rule::before {
  left: 22%;
}

.gold-rule::after {
  left: 78%;
}

/* —— Scroll skins (tattered parchment) & leather folio —— */
.scroll-panel {
  position: relative;
  isolation: isolate;
  background-color: var(--cw-paper);
  background-image:
    var(--cw-fiber),
    radial-gradient(ellipse 80% 50% at 10% 0%, rgba(255, 240, 200, 0.35), transparent 50%),
    radial-gradient(ellipse 60% 40% at 90% 100%, rgba(90, 50, 16, 0.12), transparent 55%),
    linear-gradient(180deg, #c4b594 0%, var(--cw-paper) 42%, var(--cw-paper-deep) 100%);
  color: var(--cw-paper-ink);
  border: none;
  border-radius: 2px;
  box-shadow:
    0 18px 44px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(70, 46, 18, 0.35),
    inset 0 0 40px rgba(90, 55, 18, 0.08);
}

.scroll-panel::before,
.scroll-panel::after {
  content: "";
  position: absolute;
  left: -2px;
  right: -2px;
  height: 16px;
  z-index: 2;
  pointer-events: none;
  background: url("/static/img/shared/torn-h.svg") center / 100% 100% no-repeat;
}

.scroll-panel::before {
  top: -10px;
}

.scroll-panel::after {
  bottom: -10px;
  transform: scaleY(-1);
}

.scroll-panel h2,
.scroll-panel .lede,
.hub-card.scroll-panel h2 {
  color: #f0d78a;
}

.scroll-panel .lede {
  color: #e8dcc4;
}

.scroll-panel .empty-hint,
.scroll-panel .effects-heading {
  color: #d4c4a0;
}

.folio {
  background:
    radial-gradient(ellipse 80% 40% at 50% 0%, rgba(212, 168, 75, 0.07), transparent 55%),
    linear-gradient(180deg, #1c1610 0%, #14110d 48%, #100e0a 100%);
  box-shadow: inset 0 0 0 1px var(--cw-tooling);
}

/* —— Hub —— */
.hub {
  flex: 1;
  overflow: auto;
  padding: 2rem 1.5rem 3rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hub-card {
  width: min(720px, 100%);
  background: var(--cw-panel);
  border: 1px solid var(--cw-border);
  border-radius: var(--cw-radius);
  box-shadow: var(--cw-shadow);
  padding: 1.75rem 1.75rem 2rem;
}

.hub-card.scroll-panel {
  margin-top: 0.75rem;
  padding-top: 2.1rem;
  padding-bottom: 2.15rem;
}

.hub-card.scroll-panel .btn-primary {
  box-shadow: 0 3px 0 #5a3c10, 0 6px 16px rgba(0, 0, 0, 0.28);
}

.hub-card.scroll-panel .save-list li {
  background: rgba(16, 12, 8, 0.42);
  border-color: rgba(212, 168, 75, 0.28);
}

.hub-card.scroll-panel .save-list li:hover {
  border-color: var(--cw-gold);
  box-shadow: 0 0 0 1px rgba(212, 168, 75, 0.28);
}

.hub-card.scroll-panel .save-label {
  color: #f2ebe3;
}

.hub-card.scroll-panel .save-meta {
  color: #d4c4a0;
}

.drop-btn {
  color: #ffc8c8;
  background: rgba(96, 18, 18, 0.72);
  border: 1px solid #e88888;
  border-radius: 3px;
  padding: 0.35rem 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.drop-btn:hover,
.drop-btn:focus-visible {
  color: #fff5f5;
  background: rgba(140, 24, 24, 0.88);
  border-color: #ffb0b0;
  outline: none;
}

.hub-card.scroll-panel .drop-btn {
  color: #ffd4d4;
}

.hub-card.scroll-panel .campaign-block .campaign-saves > li {
  background: rgba(10, 8, 6, 0.4);
}

.login-card.scroll-panel .model-field span,
.login-card.scroll-panel label span,
.login-card.scroll-panel label {
  color: #e8dcc4;
}

.login-form .btn-primary {
  width: 100%;
  margin-top: 0.35rem;
  min-height: 2.75rem;
}

.hub-card h2 {
  font-family: var(--font-display);
  color: var(--cw-gold);
  margin: 0 0 0.35rem;
  font-size: 1.35rem;
  letter-spacing: 0.04em;
}

.hub-card .lede {
  color: var(--cw-muted);
  margin: 0 0 1.25rem;
}

.save-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.save-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: var(--cw-panel-2);
  border: 1px solid var(--cw-border);
  border-radius: 8px;
  transition: border-color 0.15s, box-shadow 0.15s;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  /* Don't clip Load/Delete — actions keep min-content width instead */
  overflow: visible;
}

.save-list li:hover {
  border-color: var(--cw-gold-dim);
  box-shadow: var(--cw-glow);
}

.save-list .save-info {
  min-width: 0;
  flex: 1 1 10rem;
  overflow: hidden;
}

.save-list .save-label {
  font-weight: 600;
  color: var(--cw-parchment);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.save-list .save-meta {
  font-size: 0.8rem;
  color: var(--cw-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Load / Delete must never collapse on desktop (was flex-shrink + overflow:hidden). */
.save-list .save-row-actions,
.save-load-list .save-row-actions {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.4rem;
  flex: 0 0 auto;
  min-width: min-content;
  max-width: 100%;
  box-sizing: border-box;
}

.save-list .save-row-actions .btn-primary,
.save-list .save-row-actions .drop-btn,
.save-load-list .save-row-actions .btn-primary,
.save-load-list .save-row-actions .drop-btn {
  flex: 0 0 auto;
  min-width: auto;
  max-width: none;
  box-sizing: border-box;
  white-space: nowrap;
}

/* Campaign blocks: header + nested saves (enter only via save slots) */
.save-list.campaign-list > li.campaign-block,
.save-list > li.campaign-block {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.55rem;
  padding: 0.85rem 1rem 0.75rem;
}

.campaign-block .campaign-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  min-width: 0;
  width: 100%;
}

.campaign-block .campaign-saves {
  list-style: none;
  margin: 0;
  padding: 0 0 0 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  border-left: 2px solid var(--cw-border);
  width: 100%;
  box-sizing: border-box;
}

.campaign-block .campaign-saves > li {
  padding: 0.65rem 0.85rem;
  background: var(--cw-bg, rgba(0, 0, 0, 0.18));
  border: 1px solid var(--cw-border);
  border-radius: 6px;
}

.campaign-block .campaign-saves-empty {
  padding: 0.35rem 0 0.15rem 0.85rem;
  border-left: 2px solid var(--cw-border);
  font-size: 0.8rem;
}

/* —— Play layout —— */
.play {
  flex: 1;
  display: grid;
  /* Slightly wider hero column so 4:3 portraits read at natural size */
  grid-template-columns: minmax(300px, 36%) 1fr;
  min-height: 0;
  overflow: hidden;
}

.pane-left {
  min-height: 0;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(ellipse 80% 40% at 50% 0%, rgba(212, 168, 75, 0.07), transparent 55%),
    linear-gradient(180deg, #1c1610 0%, #14110d 48%, #100e0a 100%);
  border-right: 1px solid rgba(212, 168, 75, 0.22);
  box-shadow: inset -1px 0 0 rgba(0, 0, 0, 0.35);
  padding: 1rem 1.1rem 1.25rem;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* Column scrolls — never crush vitality / stats / toolbar into the portrait */
.pane-left > * {
  flex-shrink: 0;
  min-height: min-content;
}

.pane-right {
  /* Narrative 65% / suggested actions 35% of the right column */
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: transparent;
  overflow: hidden;
}

.dm-pane {
  flex: 65 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Portrait — natural landscape 4:3 (width : height) */
.portrait-frame {
  --portrait-max-h: min(40vh, 22rem);
  position: relative;
  border-radius: 4px;
  border: 3px solid var(--cw-gold-dim);
  box-shadow:
    var(--cw-shadow),
    0 0 0 1px rgba(212, 168, 75, 0.35),
    inset 0 0 0 1px rgba(212, 168, 75, 0.25);
  overflow: hidden;
  background: radial-gradient(ellipse at center, #14110c 0%, #070605 70%);
  /* Height follows width at 4:3; width capped so height never exceeds --portrait-max-h */
  aspect-ratio: 4 / 3;
  width: min(100%, calc(var(--portrait-max-h) * 4 / 3), 28rem);
  max-width: 100%;
  height: auto;
  max-height: var(--portrait-max-h);
  margin-inline: auto;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

.portrait-frame img {
  /* Cover the 4:3 frame; center crop if source ratio differs */
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: cover;
  object-position: center center;
  display: block;
  flex: 0 0 auto;
}

.portrait-frame::before,
.portrait-frame::after {
  pointer-events: none;
}

.portrait-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(212, 168, 75, 0.15);
}

.portrait-frame::before {
  content: "";
  position: absolute;
  inset: 5px;
  z-index: 1;
  border: 1px solid rgba(212, 168, 75, 0.28);
  box-shadow:
    inset 8px 8px 0 -7px rgba(212, 168, 75, 0.45),
    inset -8px -8px 0 -7px rgba(212, 168, 75, 0.45),
    inset 8px -8px 0 -7px rgba(212, 168, 75, 0.28),
    inset -8px 8px 0 -7px rgba(212, 168, 75, 0.28);
}

.hero-name {
  margin: 0.9rem 0 0.15rem;
  font-family: var(--font-display);
  font-size: 1.25rem;
  color: var(--cw-gold);
  letter-spacing: 0.03em;
  line-height: 1.25;
}

.hero-sub {
  margin: 0 0 0.75rem;
  color: var(--cw-muted);
  font-size: 0.88rem;
  line-height: 1.35;
}

/* HP / vitality — full natural size; parent column scrolls if needed */
.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  font-size: 0.88rem;
  color: var(--cw-muted);
  margin-bottom: 0.4rem;
  line-height: 1.35;
}

.stat-row #hpLabel {
  color: var(--cw-parchment);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.hp-track {
  height: 14px;
  min-height: 14px;
  background: #1c1812;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--cw-border);
  margin-bottom: 0.65rem;
}

/* Active spells / conditions — grow with content; column scroll handles overflow */
.effects-panel {
  margin: 0.35rem 0 0.75rem;
  padding: 0.5rem 0.55rem 0.55rem;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--cw-border);
  border-radius: 8px;
  border-left: 3px solid var(--cw-info);
  max-height: none;
  overflow: visible;
}

.effects-panel.effects-empty {
  opacity: 0.85;
  border-left-color: var(--cw-border);
}

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

.party-fx-line {
  margin: 0.2rem 0;
  line-height: 1.35;
}

.effects-heading {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--cw-muted);
  margin-bottom: 0.35rem;
}

.effects-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.effect-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  max-width: 100%;
  padding: 0.22rem 0.45rem;
  border-radius: 999px;
  font-size: 0.72rem;
  line-height: 1.25;
  border: 1px solid var(--cw-border);
  background: var(--cw-panel-2);
  color: var(--cw-parchment);
}

.effect-chip .fx-name {
  font-weight: 600;
}

.effect-chip .fx-time {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--cw-dice);
  opacity: 0.95;
}

.effect-chip.buff {
  border-color: rgba(106, 159, 212, 0.45);
  background: rgba(106, 159, 212, 0.1);
}

.effect-chip.buff.concentration {
  border-color: rgba(196, 165, 116, 0.55);
  background: rgba(196, 165, 116, 0.12);
}

.effect-chip.condition,
.effect-chip.status {
  border-color: rgba(212, 92, 92, 0.45);
  background: rgba(212, 92, 92, 0.1);
  color: #907373;
}

.effects-others {
  margin-top: 0.45rem;
  padding-top: 0.4rem;
  border-top: 1px solid var(--cw-border);
  font-size: 0.72rem;
  color: var(--cw-muted);
}

.effects-others .others-title {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 0.25rem;
  color: var(--cw-gold-dim);
}

.effects-others .other-line {
  margin: 0.15rem 0;
  line-height: 1.35;
  color: var(--cw-parchment-dim);
}

.effects-others .other-line strong {
  color: var(--cw-gold);
  font-weight: 600;
}

.hp-fill {
  height: 100%;
  background: linear-gradient(90deg, #8b2e2e, #d45c5c 40%, #e8a050);
  border-radius: 999px;
  transition: width 0.35s ease;
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 0.9rem;
}

.stat-chip {
  background:
    linear-gradient(180deg, rgba(212, 168, 75, 0.08), transparent 55%),
    var(--cw-panel-2);
  border: 1px solid rgba(212, 168, 75, 0.22);
  border-radius: 4px;
  padding: 0.55rem 0.6rem;
  font-size: 0.82rem;
  min-height: 2.75rem;
  box-sizing: border-box;
  box-shadow: inset 0 1px 0 rgba(255, 220, 150, 0.06);
}

.stat-chip span {
  display: block;
  color: var(--cw-muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  line-height: 1.3;
  margin-bottom: 0.15rem;
}

.stat-chip strong {
  color: var(--cw-parchment);
  font-weight: 600;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
}

/* Toolbar */
.toolbar {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin: 0.85rem 0 0.5rem;
}

.toolbar-group {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(4.4rem, 1fr));
  gap: 0.4rem;
  margin: 0;
  padding: 0.45rem 0.15rem 0.15rem;
  border: 1px solid rgba(212, 168, 75, 0.16);
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.18);
  position: relative;
}

.toolbar-group::before {
  content: attr(data-label);
  position: absolute;
  top: -0.45rem;
  left: 0.55rem;
  padding: 0 0.35rem;
  background: #16120c;
  font-family: var(--font-display);
  font-size: 0.58rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--cw-gold-dim);
  line-height: 1;
}

.tool-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  padding: 0.55rem 0.3rem;
  background: linear-gradient(180deg, #1a1612, var(--cw-panel-2));
  border: 1px solid var(--cw-border);
  border-radius: 4px;
  color: var(--cw-parchment-dim);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: border-color 0.15s, color 0.15s, background 0.15s, transform 0.12s;
}

.tool-btn:hover:not(:disabled) {
  border-color: var(--cw-gold-dim);
  color: var(--cw-gold);
  background: #1c1710;
  transform: translateY(-1px);
}

.tool-btn:disabled,
.tool-btn.combat-disabled {
  opacity: 0.4;
  cursor: not-allowed;
  filter: grayscale(0.85);
  color: #5a5248;
  border-color: rgba(48, 45, 57, 0.55);
  background: #100e0b;
  pointer-events: none;
}

.tool-btn .icon {
  font-size: 1.15rem;
  line-height: 1;
}

.scene-box {
  margin-top: 0.75rem;
  margin-bottom: 0.5rem;
  padding: 0.85rem 0.95rem 1.15rem;
  background-color: var(--cw-paper);
  background-image:
    var(--cw-fiber),
    linear-gradient(180deg, #c4b594, var(--cw-paper-deep));
  color: var(--cw-paper-ink);
  border: none;
  border-radius: 1px;
  font-size: 0.85rem;
  line-height: 1.55;
  position: relative;
  box-shadow:
    0 10px 22px rgba(0, 0, 0, 0.35),
    2px 3px 0 rgba(40, 24, 8, 0.25);
  overflow: visible;
  flex: 0 0 auto; /* never shrink in the left column flex stack */
  align-self: stretch;
  min-height: auto;
  max-height: none;
  height: auto;
}

.scene-box::before,
.scene-box::after {
  content: "";
  position: absolute;
  left: -1px;
  right: -1px;
  height: 12px;
  pointer-events: none;
  background: url("/static/img/shared/torn-h.svg") center / 100% 100% no-repeat;
}

.scene-box::before {
  top: -8px;
}

.scene-box::after {
  bottom: -8px;
  transform: scaleY(-1);
}

.scene-box strong {
  display: block;
  color: #6a4a18;
  font-family: var(--font-display);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.4rem;
  line-height: 1.3;
}

/* Full scene copy — must not clip mid-glyph on WebKit mobile */
.scene-box .scene-text,
.scene-box #sceneText {
  display: block;
  margin: 0;
  padding: 0;
  white-space: normal;
  overflow: visible;
  overflow-wrap: break-word;
  word-wrap: break-word;
  word-break: normal;
  line-height: 1.55;
  max-height: none;
  height: auto;
  -webkit-line-clamp: unset;
  line-clamp: unset;
  -webkit-box-orient: unset;
}

/* Right: log + actions */
.panel-head {
  display: flex;
  align-items: stretch;
  flex-shrink: 0;
  gap: 0;
  position: relative;
  background:
    linear-gradient(180deg, rgba(212, 168, 75, 0.08), transparent 70%),
    var(--cw-bg-elevated);
  border-bottom: 1px solid rgba(212, 168, 75, 0.22);
}

.panel-head .scene-header {
  flex: 1 1 auto;
  min-width: 0;
  border-bottom: none;
  background: transparent;
}

.panel-head-actions {
  align-items: center;
  padding: 0 0.15rem 0 0;
  margin-bottom: 0.3rem;
  background: transparent;
  border-bottom: none;
}

.panel-head-actions h3 {
  flex: 1 1 auto;
  margin: 0;
  padding: 0.15rem 0.15rem 0.15rem 0;
}

/* Expand / collapse — mobile only (see @media max-width 860px) */
.panel-expand-btn {
  display: none;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  min-width: 2.5rem;
  min-height: 2.5rem;
  margin: 0.2rem 0.35rem 0.2rem 0;
  padding: 0;
  border: 1px solid var(--cw-border);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.35);
  color: var(--cw-gold-dim);
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.panel-expand-btn:hover,
.panel-expand-btn:focus-visible {
  border-color: var(--cw-gold-dim);
  color: var(--cw-gold);
  background: #16130f;
  outline: none;
}

.panel-expand-btn[aria-expanded="true"] {
  border-color: var(--cw-gold);
  color: var(--cw-gold);
  background: rgba(212, 168, 75, 0.12);
}

.panel-expand-icon {
  display: block;
  pointer-events: none;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Full-screen panel mode (toggled on mobile via .is-expanded).
 * Hide site chrome so the expanded narrative sits on top of everything
 * and the collapse control is not trapped under the topbar stacking context.
 * Also hide the combat tracker so expand covers the whole fight UI. */
body.panel-fullscreen {
  overflow: hidden;
}

body.panel-fullscreen #app,
body.cw-combat-mode #app {
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
}
body.panel-fullscreen .topbar,
body.panel-fullscreen .topbar + .gold-rule {
  display: none !important;
}
body.panel-fullscreen #play.play {
  /* Play fills the viewport once the header is gone */
  flex: 1 1 auto;
  min-height: 0;
  max-height: 100dvh;
  overflow: hidden;
}
/* Combat tracker lives inside dm-pane — hide it so expand is true full-screen */
body.panel-fullscreen .combat-tracker {
  display: none !important;
}
/* Sibling chrome under the expanded panel (left sheet, non-expanded dock) */
body.panel-fullscreen .pane-left {
  visibility: hidden;
  pointer-events: none;
}
body.panel-fullscreen .dm-pane:not(.is-expanded),
body.panel-fullscreen .actions-dock {
  visibility: hidden;
  pointer-events: none;
}

.scene-header {
  padding: 0.65rem 1.15rem;
  background: var(--cw-bg-elevated);
  border-bottom: 1px solid var(--cw-border);
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  align-items: center;
  font-size: 0.82rem;
  color: var(--cw-muted);
}

.scene-header .loc {
  color: var(--cw-parchment);
  font-weight: 600;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: 1px solid var(--cw-border);
  background: var(--cw-panel);
}

.badge.combat {
  border-color: var(--cw-danger);
  color: #f0a0a0;
}

/* Engine combat tracker — visible HP for all combatants */
.combat-tracker {
  flex-shrink: 0;
  border-bottom: 1px solid var(--cw-border);
  background: linear-gradient(180deg, #14100c 0%, #0e0c09 100%);
  padding: 0.55rem 0.85rem 0.65rem;
  max-height: 38%;
  overflow-y: auto;
}

.combat-tracker.hidden {
  display: none !important;
}

.combat-tracker-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.35rem 0.75rem;
  margin-bottom: 0.4rem;
}

.combat-tracker-head strong {
  font-family: var(--font-display);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--cw-danger);
}

.combat-tracker-note {
  font-size: 0.68rem;
  color: var(--cw-muted);
}

.combat-tracker-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.combatant-row {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) auto auto minmax(80px, 1fr);
  gap: 0.35rem 0.55rem;
  align-items: center;
  padding: 0.35rem 0.45rem;
  border-radius: 6px;
  border: 1px solid var(--cw-border);
  background: rgba(0, 0, 0, 0.25);
  font-size: 0.78rem;
}

.combatant-row.player {
  border-color: rgba(126, 200, 163, 0.35);
}

.combatant-row.enemy {
  border-color: rgba(212, 92, 92, 0.4);
}

.combatant-row.current {
  box-shadow: inset 3px 0 0 var(--cw-gold);
  border-color: var(--cw-gold-dim);
  background: rgba(212, 168, 75, 0.08);
}

.combatant-row.dead {
  opacity: 0.55;
}

.combatant-row .c-name {
  font-weight: 600;
  color: var(--cw-parchment);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.combatant-row.enemy .c-name {
  color: #f0a8a8;
}

.combatant-row.player .c-name {
  color: var(--cw-player);
}

.combatant-row .c-meta {
  color: var(--cw-muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
}

.combatant-row .c-hp-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--cw-parchment-dim);
  text-align: right;
  white-space: nowrap;
}

.combatant-row .c-hp-track {
  height: 7px;
  background: #1c1812;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--cw-border);
}

.combatant-row .c-hp-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #8b2e2e, #d45c5c 45%, #e8a050);
  transition: width 0.3s ease;
}

.combatant-row.player .c-hp-fill {
  background: linear-gradient(90deg, #2d6b4f, #5cba8a 50%, #8fd4b0);
}

.combatant-row.dead .c-hp-fill {
  width: 0 !important;
  background: #292929;
}

.combatant-row .c-turn {
  font-size: 0.65rem;
  color: var(--cw-gold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.dm-pane {
  position: relative;
}

.log-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 1.35rem 1.25rem 1.65rem;
  scroll-behavior: smooth;
  position: relative;
  background-color: #b0a180;
  background-image:
    var(--cw-fiber),
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 27px,
      rgba(50, 32, 10, 0.08) 28px
    ),
    linear-gradient(180deg, #c4b594 0%, #ad9d7a 100%);
  box-shadow: inset 0 0 48px rgba(80, 50, 16, 0.08);
}

.dm-pane > .log-scroll::before {
  content: "";
  display: block;
  height: 12px;
  margin: -1.35rem -1.25rem 0.65rem;
  background: url("/static/img/shared/torn-h.svg") center / 100% 100% no-repeat;
  pointer-events: none;
}

.log-entry {
  margin-bottom: 0.85rem;
  padding: 0.75rem 0.9rem;
  border-radius: 2px;
  border: 1px solid rgba(90, 62, 28, 0.28);
  background: rgba(232, 220, 188, 0.38);
  color: var(--cw-paper-ink);
  animation: fadeIn 0.25s ease;
  box-shadow: 1px 2px 0 rgba(60, 36, 10, 0.08);
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.log-entry .tag {
  display: inline-block;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
  margin-bottom: 0.35rem;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
}

.log-entry.narration {
  background: linear-gradient(135deg, rgba(220, 204, 168, 0.5) 0%, rgba(196, 176, 136, 0.58) 100%);
  border-color: rgba(90, 62, 28, 0.32);
  color: var(--cw-paper-ink);
  font-family: var(--font-display);
  font-size: 0.95rem;
  line-height: 1.55;
}

.log-entry.narration .tag {
  background: rgba(74, 44, 12, 0.12);
  color: #3a2410;
}

/* Companion party-speak dialogue (after WM narration) */
.log-entry.dialogue {
  margin: 0.55rem 0.15rem 0.65rem;
  padding: 0.65rem 0.85rem;
  border-radius: 3px;
  border: 1px solid rgba(120, 82, 32, 0.4);
  background: linear-gradient(
    135deg,
    rgba(212, 168, 75, 0.18) 0%,
    rgba(255, 246, 220, 0.55) 100%
  );
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}

.log-entry.dialogue .tag {
  background: rgba(74, 44, 12, 0.1);
  color: #3a2410;
  font-family: var(--font-display);
  letter-spacing: 0.04em;
  font-size: 0.82rem;
}

.log-entry.dialogue .body {
  color: #3a2814;
  font-style: italic;
  line-height: 1.55;
}

.log-entry.player .tag {
  /* Forest ink: 30% of --cw-player is still parchment-luminance; match System contrast */
  background: rgba(42, 92, 68, 0.26);
  color: #2a5c44;
}

.log-entry.dice {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  border-color: rgba(224, 184, 74, 0.35);
}

.log-entry.dice .tag {
  /* 30% darker than --cw-dice / its wash so the chip reads on parchment */
  background: rgba(157, 129, 52, 0.156);
  color: #9d8134;
}

.log-entry.engine .tag {
  /* 30% darker than --cw-engine / its wash so the chip reads on parchment */
  background: rgba(137, 116, 81, 0.195);
  color: #897451;
}

.log-entry.system .tag,
.log-entry.status .tag {
  /* 30% darker than --cw-info / its wash so the chip reads on parchment */
  background: rgba(74, 111, 148, 0.156);
  color: #4a6f94;
}

.log-entry.error {
  border-color: rgba(212, 92, 92, 0.5);
}

.log-entry.error .tag {
  background: rgba(212, 92, 92, 0.15);
  color: var(--cw-danger);
}

.log-entry .body {
  white-space: pre-wrap;
  word-break: break-word;
}

/* Actions dock — 35% of right column (narrative 65%) */
.actions-dock {
  flex: 35 1 0;
  min-height: 0;
  max-height: none;
  display: flex;
  flex-direction: column;
  border-top: 1px solid rgba(212, 168, 75, 0.22);
  background:
    linear-gradient(180deg, rgba(212, 168, 75, 0.06), transparent 28%),
    linear-gradient(180deg, #16120c, #0c0a08);
  padding: 0.55rem 1.15rem 0.7rem;
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.35);
  overflow: hidden;
  transition: background 0.35s ease, border-color 0.35s ease, box-shadow 0.35s ease;
  position: relative;
}

.actions-dock::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -10px;
  height: 14px;
  pointer-events: none;
  background: url("/static/img/shared/torn-h-dark.svg") center / 100% 100% no-repeat;
  z-index: 2;
}

.actions-dock h3,
.panel-head-actions h3 {
  margin: 0 0 0.35rem;
  flex-shrink: 0;
  font-family: var(--font-display);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--cw-gold-dim);
  transition: color 0.35s ease;
}

.panel-head-actions h3,
.panel-head-actions h3.actions-title {
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
  line-height: 1.35;
}

.actions-title-main {
  display: inline;
  white-space: nowrap;
}

/* Unspent class powers — full-width reminder under the title (not chips).
 * Own row so mobile expand-button layout cannot clip or squeeze it away. */
.actions-available-powers {
  display: block;
  flex: 0 0 auto;
  width: 100%;
  box-sizing: border-box;
  margin: 0 0 0.4rem;
  padding: 0.15rem 0 0.2rem;
  font-family: var(--font-body, "Source Sans 3", system-ui, sans-serif);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--cw-parchment-dim, #c4b59a);
  line-height: 1.4;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  max-height: 4.2em;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.actions-available-powers[hidden] {
  display: none !important;
}

.action-grid {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 0.35rem;
  margin-bottom: 0.45rem;
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
}

.actions-dock .compose {
  flex-shrink: 0;
  margin-top: auto;
}

.action-item {
  display: inline-flex;
  align-items: stretch;
  max-width: 100%;
  min-width: 0;
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid rgba(212, 168, 75, 0.28);
  background:
    linear-gradient(180deg, rgba(212, 168, 75, 0.07), transparent 60%),
    var(--cw-panel-2);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.12s;
}

.action-item:hover {
  border-color: var(--cw-gold);
  box-shadow: 0 0 0 1px rgba(212, 168, 75, 0.2);
  transform: translateY(-1px);
}

.action-btn {
  text-align: left;
  padding: 0.5rem 0.55rem 0.5rem 0.7rem;
  background: transparent;
  border: none;
  border-radius: 0;
  color: var(--cw-text);
  font-size: 0.82rem;
  max-width: 100%;
  min-width: 0;
  flex: 1 1 auto;
  transition: background 0.15s, color 0.2s;
}

.action-btn:hover:not(:disabled) {
  background: #1c1712;
}

.action-btn:disabled {
  opacity: 0.5;
  cursor: wait;
}

.action-btn .num {
  color: var(--cw-gold);
  font-weight: 700;
  margin-right: 0.35rem;
  font-family: var(--font-mono);
}

.action-btn .action-label {
  word-break: break-word;
}

.action-copy {
  appearance: none;
  flex: 0 0 auto;
  align-self: stretch;
  min-width: 2rem;
  padding: 0.35rem 0.5rem;
  border: none;
  border-left: 1px solid var(--cw-border);
  background: rgba(0, 0, 0, 0.2);
  color: var(--cw-muted);
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.action-copy:hover,
.action-copy:focus-visible {
  color: var(--cw-gold);
  background: rgba(212, 168, 75, 0.12);
  outline: none;
}

.action-copy.copied {
  color: var(--cw-success);
  background: rgba(92, 186, 138, 0.15);
}

/* Melee / combat rounds — blood dock, amber text, fire-orange numbers */
.actions-dock.combat-melee {
  border-top-color: rgba(140, 28, 36, 0.85);
  background:
    radial-gradient(ellipse 90% 70% at 50% 0%, rgba(120, 18, 28, 0.55), transparent 65%),
    linear-gradient(180deg, #19060a 0%, #100406 45%, #0b0205 100%);
  box-shadow:
    0 -8px 28px rgba(48, 5, 7, 0.55),
    inset 0 1px 0 rgba(180, 40, 48, 0.25);
}

.actions-dock.combat-melee h3 {
  color: #ffbf3a; /* amber yellow */
  text-shadow: 0 0 12px rgba(255, 140, 40, 0.35);
}

.actions-dock.combat-melee .action-item {
  background: rgba(29, 6, 8, 0.85);
  border-color: rgba(120, 30, 38, 0.75);
}

.actions-dock.combat-melee .action-item:hover {
  border-color: #ff8c1a;
  box-shadow: 0 0 12px rgba(255, 100, 30, 0.2);
}

.actions-dock.combat-melee .action-btn {
  background: transparent;
  color: #ffc94a; /* amber yellow letters */
}

.actions-dock.combat-melee .action-btn:hover:not(:disabled) {
  background: rgba(43, 8, 11, 0.95);
}

.actions-dock.combat-melee .action-btn .num {
  color: #ff6a00; /* fire orange */
  text-shadow: 0 0 8px rgba(255, 90, 0, 0.45);
}

.actions-dock.combat-melee .action-copy {
  border-left-color: rgba(120, 30, 38, 0.75);
  background: rgba(12, 2, 5, 0.45);
  color: rgba(255, 180, 80, 0.75);
}

.actions-dock.combat-melee .action-copy:hover,
.actions-dock.combat-melee .action-copy:focus-visible {
  color: #ffbf3a;
  background: rgba(255, 106, 0, 0.15);
}

.actions-dock.combat-melee .empty-hint {
  color: rgba(255, 200, 90, 0.7);
}

.actions-dock.combat-melee .compose input {
  border-color: rgba(120, 30, 38, 0.65);
  background: rgba(17, 5, 6, 0.9);
  color: #ffc94a;
}

.actions-dock.combat-melee .compose input::placeholder {
  color: rgba(255, 180, 80, 0.45);
}

/* Post-dice combat gate — single Next instead of action chips */
.actions-dock .combat-next-item {
  flex: 1 1 100%;
  min-width: 12rem;
}

.actions-dock .combat-next-btn {
  justify-content: center;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  min-height: 2.75rem;
}

.actions-dock.combat-melee .combat-next-btn {
  color: #ffc94a;
  background: rgba(60, 12, 14, 0.9);
  border: 1px solid rgba(255, 140, 40, 0.55);
  box-shadow: 0 0 16px rgba(255, 100, 30, 0.18);
}

.actions-dock.combat-melee .combat-next-btn:hover:not(:disabled) {
  background: rgba(90, 18, 20, 0.95);
  border-color: #ffbf3a;
  box-shadow: 0 0 20px rgba(255, 140, 40, 0.35);
}

/* Next — end turn owns the dock: free-text compose is not shown */
.actions-dock.combat-next-gate .compose,
.compose.is-gated {
  display: none !important;
}

.compose {
  display: flex;
  gap: 0.5rem;
}

.compose input {
  flex: 1;
  padding: 0.7rem 0.95rem;
  background: #0c0a08;
  border: 1px solid rgba(212, 168, 75, 0.28);
  border-radius: 3px;
  outline: none;
}

.compose input:focus {
  border-color: var(--cw-gold);
  box-shadow: 0 0 0 2px rgba(212, 168, 75, 0.16);
}

.compose input::placeholder {
  color: var(--cw-muted);
  font-style: italic;
}

.btn-primary {
  padding: 0.65rem 1.15rem;
  background: linear-gradient(180deg, #e0b85a, #c9a04a 42%, #8a6520);
  color: #100b05;
  font-weight: 700;
  font-family: var(--font-display);
  border-radius: 3px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 0.78rem;
  border: 1px solid #f0d78a;
  box-shadow:
    0 2px 0 #5a3c10,
    0 4px 10px rgba(0, 0, 0, 0.35);
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.btn-primary:disabled {
  opacity: 0.55;
  cursor: wait;
}

.btn-ghost {
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--cw-border);
  border-radius: 8px;
  color: var(--cw-parchment-dim);
  background: transparent;
  font-size: 0.8rem;
}

.btn-ghost:hover {
  border-color: var(--cw-gold-dim);
  color: var(--cw-gold);
}

/* Modal — same visual language as Rest / Save / Party / Quest log */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--cw-modal-overlay);
  backdrop-filter: blur(6px);
  z-index: 220;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.modal-backdrop.open {
  display: flex;
  animation: fadeIn 0.2s ease;
}

/* Weave Master system dialogs (alert / confirm / prompt) — above other modals.
   Long OOC Ask answers must scroll inside the message pane, not clip. */
.dice-backdrop.wm-sys-backdrop {
  z-index: 400;
  align-items: center;
  justify-content: center;
  padding: max(0.75rem, env(safe-area-inset-top, 0px))
    max(0.75rem, env(safe-area-inset-right, 0px))
    max(0.75rem, env(safe-area-inset-bottom, 0px))
    max(0.75rem, env(safe-area-inset-left, 0px));
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}
.dice-backdrop.wm-sys-backdrop.open {
  display: flex;
}
.wm-sys-modal {
  width: min(520px, calc(100vw - 1.5rem));
  max-width: 100%;
  max-height: min(85dvh, 85vh, 720px);
  margin: auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  text-align: left;
  box-sizing: border-box;
  background: var(--cw-modal-surface);
  color: var(--cw-parchment);
}
.wm-sys-modal .dice-header {
  flex-shrink: 0;
  justify-content: flex-start;
}
.wm-sys-modal .wm-sys-message {
  /* Flex child scrolls when the answer is longer than the modal */
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-wrap: break-word;
  margin: 0 0 1rem;
  padding: 0.15rem 0.35rem 0.15rem 0;
  color: var(--cw-parchment, #e8dfc8);
  line-height: 1.5;
  font-size: 0.95rem;
  text-align: left;
}
/* Text field only for Ask (prompt). .model-field { display:flex } would otherwise override [hidden]. */
.wm-sys-modal .wm-sys-input-wrap {
  display: none !important;
  flex-shrink: 0;
  margin: 0 0 1rem;
}
.wm-sys-modal.wm-sys-has-input .wm-sys-input-wrap {
  display: flex !important;
}
.wm-sys-modal .wm-sys-input-wrap input {
  width: 100%;
  box-sizing: border-box;
}
.wm-sys-modal .wm-sys-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
  flex-shrink: 0;
}

/* OOC Ask conversation — transcript + follow-up compose */
.wm-sys-modal.wm-sys-ooc-open .wm-sys-message {
  margin-bottom: 0.65rem;
}
.wm-sys-modal .wm-sys-ooc-compose {
  display: none;
  flex-direction: column;
  gap: 0.5rem;
  flex-shrink: 0;
  margin-top: 0.15rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--cw-border);
}
.wm-sys-modal.wm-sys-ooc-open .wm-sys-ooc-compose {
  display: flex;
}
.wm-sys-modal.wm-sys-ooc-open .wm-sys-ooc-compose[hidden] {
  display: none !important;
}
.wm-sys-ooc-input {
  width: 100%;
  min-height: 44px;
  box-sizing: border-box;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--cw-border);
  background: var(--cw-bg);
  color: var(--cw-text);
  font-family: var(--font-body, inherit);
  font-size: 16px; /* avoid iOS zoom */
}
.wm-sys-ooc-input:focus {
  outline: none;
  border-color: var(--cw-gold-dim);
  box-shadow: 0 0 0 2px rgba(212, 168, 75, 0.15);
}
.wm-sys-ooc-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
}
.wm-sys-ooc-actions .btn-primary,
.wm-sys-ooc-actions .btn-ghost {
  min-height: 44px;
  min-width: 5.5rem;
}
.wm-sys-ooc-status {
  margin: 0;
  font-size: 0.8rem;
}
.wm-sys-message .ooc-turn {
  margin: 0 0 0.85rem;
  padding: 0 0 0.75rem;
  border-bottom: 1px solid rgba(212, 168, 75, 0.12);
}
.wm-sys-message .ooc-turn:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}
.wm-sys-message .ooc-you,
.wm-sys-message .ooc-wm {
  display: block;
  margin: 0 0 0.35rem;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}
.wm-sys-message .ooc-label {
  display: block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--cw-gold-dim);
  margin-bottom: 0.2rem;
}
.wm-sys-message .ooc-wm .ooc-label {
  color: var(--cw-gold);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.modal {
  width: min(520px, 100%);
  max-height: min(85vh, 85dvh, 760px);
  background: var(--cw-modal-surface);
  border: 2px solid var(--cw-gold-dim);
  border-radius: 4px;
  box-shadow:
    var(--cw-shadow),
    0 0 40px rgba(212, 168, 75, 0.15),
    inset 0 0 0 1px rgba(212, 168, 75, 0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: var(--cw-parchment);
  min-height: 0;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.95rem 1.15rem;
  border-bottom: 1px solid var(--cw-border);
  background: linear-gradient(180deg, var(--cw-panel-2), transparent);
  flex-shrink: 0;
}

.modal-header h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--cw-gold);
  letter-spacing: 0.05em;
  font-weight: 600;
}

/* —— Bound codex (sheet / spellbook / quest journal) —— */
.modal.book-modal {
  width: min(760px, 100%);
  max-height: min(90vh, 90dvh, 880px);
  background:
    linear-gradient(90deg, #2a1c10 0%, #1a120c 8%, #1a120c 92%, #2a1c10 100%);
  border: 3px solid #8a6520;
  border-radius: 3px;
  box-shadow:
    var(--cw-shadow),
    0 0 0 1px rgba(212, 168, 75, 0.35),
    inset 0 0 0 6px rgba(20, 12, 6, 0.55);
}

.modal.book-modal .modal-header {
  background: linear-gradient(180deg, #24180e, transparent);
  border-bottom-color: rgba(212, 168, 75, 0.28);
}

.modal.book-modal .modal-body.book-body {
  background:
    var(--cw-fiber),
    linear-gradient(90deg, #a18d66 0%, #baad90 7%, #c4b594 50%, #baad90 93%, #a18d66 100%);
  color: var(--cw-paper-ink);
}

.codex {
  position: relative;
  min-height: 12rem;
}

.codex-gutter {
  display: none;
}

.codex-pages .themed-doc,
.codex-pages .sheet-modal-wrap .themed-doc {
  color: var(--cw-paper-ink);
}

.book-body .doc-section {
  color: #6a3a12;
  border-bottom-color: rgba(106, 58, 18, 0.35);
  font-size: 0.82rem;
  letter-spacing: 0.1em;
}

.book-body .doc-line {
  color: #2a1c10;
}

.book-body .doc-detail {
  color: #4a3824;
  border-left-color: rgba(138, 80, 24, 0.4);
  background: rgba(255, 248, 228, 0.28);
}

.book-body .doc-lede,
.book-body .empty-hint {
  color: #6a5840;
}

.book-body .doc-spell-name {
  color: #7a3c10;
  font-family: var(--font-display);
  font-size: 0.95rem;
  letter-spacing: 0.03em;
  border-left: none;
  padding-left: 0;
  margin-top: 0.7rem;
  background: transparent;
}

.book-modal .sheet-modal-footer {
  border-top-color: rgba(106, 58, 18, 0.28);
}

@media (min-width: 700px) {
  .codex {
    display: grid;
    grid-template-columns: 14px 1fr;
    gap: 0;
  }

  .codex-gutter {
    display: block;
    background:
      linear-gradient(90deg, rgba(60, 32, 10, 0.28), transparent 70%),
      repeating-linear-gradient(
        180deg,
        transparent 0 18px,
        rgba(80, 40, 10, 0.08) 18px 19px
      );
    border-radius: 2px 0 0 2px;
    box-shadow: inset -6px 0 12px rgba(40, 20, 6, 0.18);
  }

  .book-spells .codex-pages .themed-doc {
    column-count: 2;
    column-gap: 2.2rem;
    column-rule: 1px solid rgba(106, 58, 18, 0.18);
  }

  .book-spells .codex-pages .doc-section {
    break-after: avoid;
    column-span: none;
  }
}

.modal-close {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  color: var(--cw-muted);
  font-size: 1.25rem;
  line-height: 1;
  border: 1px solid transparent;
  flex-shrink: 0;
}

.modal-close:hover {
  background: var(--cw-panel-2);
  color: var(--cw-text);
  border-color: var(--cw-border);
}

.modal-body {
  padding: 1.1rem 1.2rem 1.25rem;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  font-family: var(--font-body);
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--cw-parchment);
  background: transparent;
  white-space: normal;
}

.modal-body.items-ui {
  font-family: var(--font-body);
  white-space: normal;
}

/* Readable document layout (sheet / spells / quest) — gold & parchment only */
.themed-doc {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  color: var(--cw-parchment);
}

.themed-doc .doc-section {
  margin: 0.95rem 0 0.35rem;
  font-family: var(--font-display);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--cw-gold);
  border-bottom: 1px solid rgba(212, 168, 75, 0.28);
  padding-bottom: 0.28rem;
}

/* Character sheet footer (other sheets / close) */
.sheet-modal-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-height: 0;
}

.sheet-codex-flow {
  display: block;
}

.sheet-codex-flow .themed-doc,
.themed-doc.has-portrait {
  display: block;
}

.themed-doc.has-portrait::after {
  content: "";
  display: table;
  clear: both;
}

.sheet-codex-portrait {
  float: left;
  width: 35%;
  max-width: 35%;
  margin: 0 1.15rem 0.85rem 0;
  padding: 0;
}

.sheet-codex-portrait img {
  display: block;
  width: 100%;
  height: auto;
  min-height: 7rem;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  object-position: center top;
  background: #1a1410;
  border: 2px solid #8a6520;
  box-shadow:
    0 8px 18px rgba(0, 0, 0, 0.28),
    inset 0 0 0 1px rgba(212, 168, 75, 0.35);
}

@media (max-width: 560px) {
  .sheet-codex-portrait {
    width: 32%;
    max-width: 32%;
    margin: 0 0.75rem 0.65rem 0;
  }
}
.sheet-modal-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--cw-border);
  clear: both;
}
.sheet-party-list {
  margin: 0;
  padding: 0;
}

.themed-doc .doc-line {
  color: var(--cw-parchment);
  font-size: 0.9rem;
  line-height: 1.55;
  padding: 0.18rem 0;
}

.themed-doc .doc-detail {
  color: var(--cw-parchment-dim);
  font-size: 0.84rem;
  line-height: 1.5;
  padding: 0.14rem 0 0.14rem 0.75rem;
  border-left: 2px solid rgba(212, 168, 75, 0.28);
  margin: 0.1rem 0 0.28rem 0.15rem;
  background: transparent;
}

.themed-doc .doc-gap {
  height: 0.55rem;
}

.themed-doc .doc-lede {
  color: var(--cw-muted);
  font-size: 0.82rem;
  margin-bottom: 0.5rem;
  line-height: 1.5;
}

/* Spell / feature entries get breathing room */
.themed-doc .doc-detail + .doc-detail {
  margin-top: 0.05rem;
}

/* Spellbook names — copper/gold accent, same family as the rest of the UI */
.themed-doc .doc-line.doc-spell-name,
.themed-doc .doc-detail.doc-spell-name {
  color: var(--cw-gold);
  font-weight: 600;
  margin-top: 0.45rem;
  border-left-color: rgba(212, 168, 75, 0.45);
}

/* Book pages: ink on paper. These MUST follow .themed-doc so cream-on-cream
   body text does not win the cascade (sheet / spells / quest journal). */
.modal.book-modal .modal-body.book-body {
  color: #1a1208;
}

.modal.book-modal .book-body .themed-doc,
.modal.book-modal .book-body .themed-doc .doc-line,
.modal.book-modal .book-body .codex-pages {
  color: #1a1208;
}

.modal.book-modal .book-body .themed-doc .doc-section {
  color: #5a2c08;
  border-bottom-color: rgba(90, 44, 8, 0.45);
}

.modal.book-modal .book-body .themed-doc .doc-detail {
  color: #2c1c0c;
  border-left-color: rgba(90, 44, 8, 0.4);
  background: rgba(255, 250, 236, 0.45);
}

.modal.book-modal .book-body .themed-doc .doc-lede,
.modal.book-modal .book-body .empty-hint {
  color: #4a3824;
}

.modal.book-modal .book-body .themed-doc .doc-spell-name,
.modal.book-modal .book-body .themed-doc .doc-line.doc-spell-name,
.modal.book-modal .book-body .themed-doc .doc-detail.doc-spell-name {
  color: #6a2808;
  border-left-color: transparent;
}

.modal.book-modal .sheet-modal-footer {
  border-top-color: rgba(90, 44, 8, 0.28);
}

.modal.book-modal .sheet-modal-footer .btn-ghost {
  color: #3a2814;
  border-color: rgba(90, 44, 8, 0.35);
}

.items-list {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
}

.items-list li {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  padding: 0;
  border-bottom: 1px solid var(--cw-border);
}

.items-list li:hover {
  background: var(--cw-panel-2);
}

.items-list li.is-open {
  background: rgba(22, 19, 15, 0.95);
}

.items-list .drop-btn {
  font-size: 0.72rem;
  color: var(--cw-danger);
  border: 1px solid rgba(212, 92, 92, 0.4);
  border-radius: 4px;
  padding: 0.15rem 0.45rem;
}

.take-row {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.item-row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.45rem 0.55rem;
  width: 100%;
  box-sizing: border-box;
  /* Allow name row + actions to stack on narrow portrait without overlay */
  flex-wrap: wrap;
  position: relative;
  z-index: 1;
}

.item-label {
  min-width: 0;
  flex: 1;
}

.item-label-toggle {
  appearance: none;
  background: transparent;
  border: 0;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  padding: 0.15rem 0.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
  flex: 1 1 auto;
  /* Touch: keep a real hit target; never collapse under Share/Drop */
  min-height: 44px;
  justify-content: center;
  position: relative;
  z-index: 1;
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(212, 168, 75, 0.2);
}

.item-label-toggle:hover .item-label-title {
  color: var(--cw-gold);
}

.item-label-title {
  font-weight: 600;
  color: var(--cw-parchment);
}

.item-tags {
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--cw-muted);
}

.item-detail {
  padding: 0 0.7rem 0.65rem 0.85rem;
  border-top: 1px dashed rgba(212, 168, 75, 0.18);
  margin: 0 0.35rem 0.35rem;
  /* Always in the document flow when open — never under Share/Drop hit targets */
  position: relative;
  z-index: 0;
  clear: both;
}

.item-detail[hidden] {
  display: none !important;
}

.item-detail-line {
  margin: 0.35rem 0 0;
  font-size: 0.84rem;
  line-height: 1.45;
  color: var(--cw-parchment-dim);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.item-detail-line.muted {
  color: var(--cw-muted);
  font-style: italic;
}

.item-actions {
  display: flex;
  gap: 0.35rem;
  flex-shrink: 0;
}

.share-btn {
  font-size: 0.72rem;
  color: var(--cw-info);
  border: 1px solid rgba(106, 159, 212, 0.45);
  border-radius: 4px;
  padding: 0.15rem 0.45rem;
}

.share-btn:hover {
  background: rgba(106, 159, 212, 0.12);
}

.share-panel {
  margin-top: 1rem;
  padding: 0.85rem 0.9rem;
  border: 1px solid var(--cw-gold-dim);
  border-radius: 8px;
  background: var(--cw-panel-2);
  box-shadow: var(--cw-glow);
}

.share-title {
  font-family: var(--font-display);
  color: var(--cw-gold);
  font-size: 0.95rem;
  margin-bottom: 0.65rem;
}

.share-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.55rem;
  font-size: 0.78rem;
  color: var(--cw-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.share-select,
.share-qty {
  padding: 0.45rem 0.55rem;
  background: #08070c;
  border: 1px solid var(--cw-border);
  border-radius: 6px;
  color: var(--cw-text);
  font-size: 0.9rem;
  text-transform: none;
  letter-spacing: normal;
}

.share-actions {
  display: flex;
  gap: 0.45rem;
  margin-top: 0.35rem;
}

/* Party picker */
.party-hint {
  margin: 0 0 0.85rem;
  font-size: 0.85rem;
  color: var(--cw-muted);
  line-height: 1.45;
}

.party-hint strong {
  color: var(--cw-gold);
}

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

.party-list li.party-row {
  display: block;
  padding: 0;
  border-bottom: 1px solid var(--cw-border);
}

.party-list li.party-row:hover {
  background: transparent;
}

.party-pick {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  text-align: left;
  padding: 0.75rem 0.7rem;
  border-radius: 8px;
  color: var(--cw-parchment);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s, border-color 0.15s;
}

.party-pick:hover:not(:disabled) {
  background: var(--cw-panel-2);
  border-color: var(--cw-gold-dim);
  box-shadow: inset 3px 0 0 var(--cw-gold);
}

.party-pick:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Lead-switch stasis: WM is regenerating suggestions for the new lead */
.party-picker.is-stasis {
  pointer-events: none;
  position: relative;
}

.party-picker.is-stasis .party-list {
  opacity: 0.4;
  filter: grayscale(0.35);
}

.party-picker.is-stasis .party-pick {
  cursor: wait;
}

.party-stasis {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin: 0 0 0.85rem;
  padding: 0.7rem 0.85rem;
  border-radius: 8px;
  border: 1px solid rgba(212, 168, 75, 0.4);
  background: rgba(16, 12, 29, 0.95);
  color: var(--cw-gold);
  font-size: 0.88rem;
  pointer-events: none;
}

.party-stasis .spinner {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border-width: 2px;
}

.party-stasis-text {
  line-height: 1.35;
}

.modal-backdrop.is-stasis .modal-close {
  opacity: 0.35;
  pointer-events: none;
  cursor: wait;
}

.actions-dock.is-stasis,
.action-grid.is-stasis {
  opacity: 0.45;
  filter: grayscale(0.25);
  pointer-events: none;
  cursor: wait;
}

.action-grid.is-stasis .action-btn {
  cursor: wait;
}

.party-row.is-lead .party-pick {
  background: rgba(212, 168, 75, 0.1);
  border-color: rgba(212, 168, 75, 0.35);
  box-shadow: inset 3px 0 0 var(--cw-gold);
}

.party-pick-main {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.party-pick-main strong {
  color: var(--cw-gold);
  font-family: var(--font-display);
  font-size: 0.98rem;
}

.party-pick-sub {
  font-size: 0.78rem;
  color: var(--cw-muted);
}

.party-badge {
  flex-shrink: 0;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--cw-gold);
  border: 1px solid var(--cw-gold-dim);
  border-radius: 999px;
  padding: 0.2rem 0.5rem;
}

.take-row input {
  flex: 1;
  padding: 0.5rem 0.65rem;
  background: #0c0a07;
  border: 1px solid var(--cw-border);
  border-radius: 6px;
}

/* Loading overlay */
.busy-bar {
  display: none;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 1rem;
  background: #16120e;
  border-top: 1px solid var(--cw-gold-dim);
  color: var(--cw-gold);
  font-size: 0.85rem;
  flex-shrink: 0;
}

.busy-bar.show {
  display: flex;
}

.busy-bar[hidden] {
  display: none !important;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--cw-gold-dim);
  border-top-color: var(--cw-gold);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.hidden {
  display: none !important;
}

/* —— Dice / Rest / Quest log / Save-Load / Level-up / WM system (shared shell) —— */
.dice-backdrop {
  position: fixed;
  inset: 0;
  z-index: 280;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: var(--cw-modal-overlay);
  backdrop-filter: blur(6px);
}

.dice-backdrop.open {
  display: flex;
  animation: fadeIn 0.2s ease;
}

.dice-modal {
  width: min(420px, 100%);
  background: var(--cw-modal-surface);
  border: 1px solid var(--cw-gold-dim);
  border-radius: 14px;
  box-shadow: var(--cw-shadow), 0 0 40px rgba(212, 168, 75, 0.15);
  padding: 1.35rem 1.4rem 1.5rem;
  text-align: center;
  color: var(--cw-parchment);
  box-sizing: border-box;
}

/* All dice-modal variants inherit warm surface (quest log, rest, save, tokens, wizard…) */
.dice-modal.rest-modal,
.dice-modal.quest-log-modal,
.dice-modal.save-load-modal,
.dice-modal.tokens-modal,
.dice-modal.model-modal,
.dice-modal.levelup-modal,
.dice-modal.campaign-wizard-modal,
.dice-modal.wm-sys-modal {
  background: var(--cw-modal-surface);
  color: var(--cw-parchment);
}

.dice-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.dice-header h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.2rem;
  color: var(--cw-gold);
  letter-spacing: 0.06em;
}

.dice-icon {
  font-size: 1.4rem;
  color: var(--cw-gold);
  animation: diceIdle 2.5s ease-in-out infinite;
}

@keyframes diceIdle {
  0%,
  100% {
    transform: rotate(-8deg);
  }
  50% {
    transform: rotate(8deg);
  }
}

.dice-sub {
  margin: 0 0 0.85rem;
  font-size: 0.85rem;
  color: var(--cw-muted);
}

.dice-list {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  text-align: left;
}

.dice-list li {
  padding: 0.5rem 0.65rem;
  margin-bottom: 0.35rem;
  background: var(--cw-panel-2);
  border: 1px solid var(--cw-border);
  border-radius: 8px;
  font-size: 0.88rem;
}

.dice-list .dice-desc {
  display: block;
  color: var(--cw-parchment);
  font-weight: 600;
}

.dice-list .dice-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--cw-dice);
  margin-top: 0.15rem;
}

.dice-stage {
  position: relative;
  height: 96px;
  display: grid;
  place-items: center;
  margin-bottom: 0.85rem;
}

.die-face {
  width: 72px;
  height: 72px;
  border-radius: 14px;
  background: linear-gradient(145deg, #1c1712, #12100c);
  border: 2px solid var(--cw-gold-dim);
  box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.45), 0 4px 16px rgba(0, 0, 0, 0.4);
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--cw-gold);
  cursor: pointer;
  user-select: none;
}

.die-face:hover {
  border-color: var(--cw-gold);
  box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.45), 0 0 16px rgba(212, 168, 75, 0.25);
}

.die-face:focus-visible {
  outline: 2px solid var(--cw-gold);
  outline-offset: 3px;
}

.die-face.spinning {
  animation: dieSpin 0.12s linear infinite;
  color: var(--cw-parchment-dim);
}

@keyframes dieSpin {
  from {
    transform: rotate(0deg) scale(1);
  }
  50% {
    transform: rotate(180deg) scale(1.08);
  }
  to {
    transform: rotate(360deg) scale(1);
  }
}

.die-face.reveal {
  animation: dieReveal 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.2);
  border-color: var(--cw-gold);
  color: #999586;
  text-shadow: 0 0 12px rgba(212, 168, 75, 0.6);
}

@keyframes dieReveal {
  0% {
    transform: scale(0.6) rotate(-20deg);
    opacity: 0.4;
  }
  100% {
    transform: scale(1) rotate(0);
    opacity: 1;
  }
}

.dice-spinner {
  position: absolute;
  width: 88px;
  height: 88px;
  border: 3px solid transparent;
  border-top-color: var(--cw-gold);
  border-right-color: var(--cw-copper);
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
}

.dice-result {
  margin: 0 0 1rem;
  padding: 0.65rem 0.75rem;
  background: rgba(224, 184, 74, 0.08);
  border: 1px solid rgba(224, 184, 74, 0.35);
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  color: var(--cw-parchment);
  /* Long initiative lists: scroll while the 5s hold lets you read */
  max-height: min(40vh, 280px);
  overflow-y: auto;
  text-align: left;
  -webkit-overflow-scrolling: touch;
  text-align: left;
  white-space: pre-wrap;
}

.dice-result .hit {
  color: var(--cw-success);
  font-weight: 700;
}

.dice-result .miss,
.dice-result .fail {
  color: var(--cw-danger);
  font-weight: 700;
}

.dice-roll-btn {
  width: 100%;
  padding: 0.85rem 1rem;
  font-size: 0.9rem;
}

.dice-roll-btn:disabled {
  opacity: 0.65;
  cursor: wait;
}

/* Ask picker — step 1: WM vs party; step 2: Lead asks … names */
.ask-picker {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.ask-intro {
  margin: 0;
  color: var(--cw-muted);
  font-size: 0.9rem;
}
.ask-intro-lead {
  font-size: 1rem;
  color: var(--cw-parchment);
}
.ask-intro-lead strong {
  font-family: var(--font-display);
  color: var(--cw-gold);
  font-weight: 600;
}
.ask-targets {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.ask-target-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  width: 100%;
  text-align: left;
  padding: 0.7rem 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--cw-border);
  background: rgba(0, 0, 0, 0.28);
  color: var(--cw-text);
  cursor: pointer;
  font: inherit;
}
.ask-target-btn:hover:not(:disabled):not(.is-disabled) {
  border-color: rgba(212, 168, 75, 0.45);
  background: rgba(212, 168, 75, 0.1);
}
.ask-target-btn:disabled,
.ask-target-btn.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.ask-target-btn strong {
  font-family: var(--font-display);
  color: var(--cw-gold);
  font-size: 0.95rem;
}
.ask-target-btn span {
  font-size: 0.78rem;
  color: var(--cw-muted);
}
.ask-back-row {
  margin-top: 0.25rem;
}
.ask-back-btn {
  font-size: 0.85rem;
  color: var(--cw-muted);
  padding: 0.35rem 0.5rem;
}
.ask-back-btn:hover {
  color: var(--cw-gold);
}

/* Level-up modal — must fit viewport with internal scroll (never clip top/bottom) */
.levelup-backdrop[hidden] {
  display: none !important;
}
.dice-backdrop.levelup-backdrop {
  z-index: 220;
  /* top-align so tall content can scroll within the overlay */
  align-items: flex-start;
  justify-content: center;
  padding: max(0.75rem, env(safe-area-inset-top, 0px))
    max(0.75rem, env(safe-area-inset-right, 0px))
    max(0.75rem, env(safe-area-inset-bottom, 0px))
    max(0.75rem, env(safe-area-inset-left, 0px));
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}
.levelup-backdrop.open {
  display: flex;
}
.levelup-modal.dice-modal,
.levelup-modal {
  width: min(540px, calc(100vw - 1.5rem));
  max-width: 100%;
  /* Cap to viewport; flex children scroll inside */
  max-height: min(88vh, 720px);
  height: auto;
  margin: 0.5rem auto;
  padding: 1rem 1.05rem 1.05rem;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  text-align: left;
  box-sizing: border-box;
  background: var(--cw-modal-surface);
  color: var(--cw-parchment);
}
.levelup-modal .dice-header {
  flex-shrink: 0;
  justify-content: flex-start;
  margin-bottom: 0.25rem;
}
.levelup-modal .dice-sub {
  flex-shrink: 0;
  text-align: left;
  margin: 0 0 0.35rem;
  font-size: 0.88rem;
  line-height: 1.35;
}
.levelup-progress {
  flex-shrink: 0;
  font-size: 0.78rem;
  color: var(--cw-muted);
  margin: 0 0 0.5rem;
  letter-spacing: 0.02em;
}
.levelup-body {
  /* Critical: min-height 0 lets flex child shrink and scroll */
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 0.15rem 0.35rem 0.35rem 0;
  margin: 0 0 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  scrollbar-gutter: stable;
}
.levelup-body::-webkit-scrollbar {
  width: 8px;
}
.levelup-body::-webkit-scrollbar-thumb {
  background: rgba(212, 168, 75, 0.35);
  border-radius: 6px;
}
.levelup-step {
  border: 1px solid var(--cw-border);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.28);
  padding: 0.65rem 0.75rem;
  flex-shrink: 0;
}
.levelup-step h3 {
  margin: 0 0 0.3rem;
  font-family: var(--font-display);
  font-size: 0.92rem;
  color: var(--cw-gold);
  font-weight: 600;
}
.levelup-step .levelup-prompt {
  margin: 0 0 0.55rem;
  font-size: 0.82rem;
  color: var(--cw-muted);
  line-height: 1.35;
}
.levelup-opt {
  display: flex;
  gap: 0.55rem;
  align-items: flex-start;
  padding: 0.45rem 0.5rem;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  margin-bottom: 0.3rem;
}
.levelup-opt:hover {
  background: rgba(212, 168, 75, 0.06);
  border-color: rgba(212, 168, 75, 0.2);
}
.levelup-opt.is-selected {
  background: rgba(212, 168, 75, 0.12);
  border-color: rgba(212, 168, 75, 0.45);
}
.levelup-opt input {
  margin-top: 0.2rem;
  flex-shrink: 0;
}
.levelup-opt .opt-text {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
  flex: 1 1 auto;
}
.levelup-opt .opt-label {
  display: block;
  font-weight: 600;
  color: var(--cw-text);
  font-size: 0.9rem;
  line-height: 1.3;
}
.levelup-opt .opt-detail {
  display: block;
  font-size: 0.78rem;
  color: var(--cw-muted);
  margin-top: 0;
  white-space: pre-wrap;
  line-height: 1.4;
  word-break: break-word;
}
.levelup-asi-modes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.55rem;
}
.levelup-asi-modes label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--cw-parchment);
}
.levelup-error {
  flex-shrink: 0;
  color: var(--cw-danger);
  font-size: 0.85rem;
  margin: 0.25rem 0 0;
}
.levelup-error.hidden {
  display: none;
}
.levelup-actions {
  flex-shrink: 0;
  margin-top: 0.35rem;
  padding-top: 0.35rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.levelup-actions .btn-primary {
  width: 100%;
  padding: 0.75rem 1rem;
}
.levelup-auto-note {
  font-size: 0.86rem;
  color: var(--cw-success);
  margin: 0;
  line-height: 1.35;
}
.levelup-deferred {
  font-size: 0.8rem;
  color: var(--cw-muted);
  font-style: italic;
}

@media (max-height: 640px) {
  .levelup-modal.dice-modal,
  .levelup-modal {
    max-height: 92vh;
    margin: 0.35rem auto;
    padding: 0.75rem 0.85rem 0.85rem;
  }
  .levelup-step {
    padding: 0.5rem 0.6rem;
  }
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Quest log modal */
.quest-log-modal {
  position: relative;
  width: min(720px, 100%);
  height: min(92dvh, 92vh, 900px);
  max-height: min(92dvh, 92vh, 900px);
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  background:
    linear-gradient(90deg, #2a1c10 0%, #1a120c 7%, #1a120c 93%, #2a1c10 100%);
  color: var(--cw-paper-ink);
  text-align: left;
  border: 3px solid #8a6520;
  border-radius: 3px;
  box-shadow:
    var(--cw-shadow),
    0 0 0 1px rgba(212, 168, 75, 0.35),
    inset 0 0 0 6px rgba(20, 12, 6, 0.45);
}

.quest-log-modal .dice-header,
.quest-log-modal .dice-sub {
  color: var(--cw-parchment);
}

.quest-log-modal .dice-sub {
  color: var(--cw-parchment-dim);
}

.quest-log-modal .dice-sub .ql-now {
  color: var(--cw-gold);
  font-weight: 700;
  font-family: var(--font-display);
  letter-spacing: 0.03em;
}

.quest-log-modal .quest-log-chrome,
.quest-log-modal .dice-sub,
.quest-log-modal .rest-cancel {
  flex-shrink: 0;
}

.quest-log-chrome {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin: 0 0 0.55rem;
  min-height: 0;
}

.quest-log-doc-nav {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
}

.quest-log-doc-nav h2 {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--cw-gold);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.quest-log-doc-btn {
  appearance: none;
  flex: 0 0 auto;
  width: 2.15rem;
  height: 2.15rem;
  padding: 0;
  border: 1px solid rgba(212, 168, 75, 0.35);
  border-radius: 3px;
  background: linear-gradient(180deg, #2a1e12, #1a140e);
  color: var(--cw-gold);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}

.quest-log-doc-btn:hover:not(:disabled),
.quest-log-doc-btn:focus-visible:not(:disabled) {
  border-color: var(--cw-gold);
  color: var(--cw-parchment);
  outline: none;
}

.quest-log-doc-btn:disabled {
  opacity: 0.28;
  color: #8a8070;
  cursor: not-allowed;
}

.quest-log-body {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.quest-log-jump {
  position: absolute;
  right: 0.45rem;
  z-index: 6;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1px solid rgba(212, 168, 75, 0.55);
  border-radius: 3px;
  background: rgba(26, 18, 12, 0.72);
  color: var(--cw-gold);
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0.6;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

.quest-log-to-top {
  top: 0.45rem;
}

.quest-log-to-bottom {
  bottom: 0.45rem;
}

.quest-log-jump:hover,
.quest-log-jump:focus-visible {
  opacity: 1;
  outline: none;
  border-color: var(--cw-gold);
}

.quest-log-search-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.55rem;
}

.quest-log-search-wrap {
  display: block;
  flex: 1 1 12rem;
  min-width: 0;
}

.quest-log-find {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex: 0 1 auto;
}

.quest-log-find[hidden] {
  display: none !important;
}

.quest-log-find-count {
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  color: var(--cw-parchment-dim);
  font-family: var(--font-mono);
  min-width: 3.2rem;
  text-align: right;
}

.quest-log-find-btn {
  appearance: none;
  border: 1px solid rgba(212, 168, 75, 0.35);
  background: linear-gradient(180deg, #2a1e12, #1a140e);
  color: var(--cw-parchment-dim);
  border-radius: 2px;
  padding: 0.32rem 0.55rem;
  font-family: var(--font-display);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
}

.quest-log-find-btn:hover:not(:disabled),
.quest-log-find-btn:focus-visible:not(:disabled) {
  border-color: var(--cw-gold-dim);
  color: var(--cw-parchment);
  outline: none;
}

.quest-log-find-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.quest-log-search {
  width: 100%;
  box-sizing: border-box;
  padding: 0.55rem 0.75rem;
  border-radius: 3px;
  border: 1px solid rgba(212, 168, 75, 0.28);
  background: #120e0a;
  color: var(--cw-parchment);
  font-size: 0.9rem;
}

.quest-log-search::placeholder {
  color: var(--cw-muted);
}

.quest-log-search:focus {
  outline: none;
  border-color: var(--cw-gold-dim);
}

.quest-log-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  max-height: none;
  margin: 0 0 0.85rem;
  padding: 1.1rem 2.8rem 1.35rem 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  border: none;
  border-radius: 2px;
  background-color: #b0a180;
  background-image:
    var(--cw-fiber),
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 27px,
      rgba(50, 32, 10, 0.08) 28px
    ),
    linear-gradient(180deg, #c4b594, #b0a180);
  color: var(--cw-paper-ink);
  box-shadow: inset 0 0 40px rgba(80, 50, 16, 0.08);
}

.quest-log-rubric {
  font-family: var(--font-display);
  font-size: 1.15rem;
  letter-spacing: 0.04em;
  color: #6a3a12;
  text-align: center;
  margin: 0.15rem 0 0.85rem;
  padding-bottom: 0.45rem;
  border-bottom: 1px solid rgba(106, 58, 18, 0.35);
}

.quest-log-scene {
  margin: 0.85rem 0 0.25rem;
  padding: 0;
  font-family: var(--font-display);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #7a4a18;
  border-bottom: 1px solid rgba(122, 74, 24, 0.28);
}

.quest-log-scene.quest-log-marker {
  text-align: center;
  letter-spacing: 0.08em;
  margin: 1rem 0 0.65rem;
  border-bottom: none;
  color: #6a3a12;
}

.quest-log-entry {
  padding: 0.2rem 0 0.45rem;
  border-radius: 0;
  border: none;
  background: transparent;
  text-align: left;
}

.quest-log-entry.narration {
  border-left: none;
}

.quest-log-entry.player {
  border-left: none;
  background: transparent;
  font-style: italic;
  padding-left: 0.85rem;
}

.quest-log-entry.is-match {
  box-shadow: inset 0 0 0 1px rgba(255, 200, 90, 0.35);
}

.quest-log-entry.is-hidden {
  display: none;
}

.quest-log-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.35rem 0.75rem;
  margin-bottom: 0.4rem;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
}

.quest-log-meta time {
  color: #8a6520;
  font-family: var(--font-mono);
  font-weight: 500;
}

.quest-log-meta .quest-log-who {
  color: #6a5840;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.65rem;
  font-weight: 600;
}

.quest-log-entry.player .quest-log-who {
  color: #8a4a28;
}

.quest-log-text {
  font-size: 0.92rem;
  line-height: 1.6;
  color: #2a1c10;
  font-family: var(--font-display);
  white-space: pre-wrap;
  word-break: break-word;
}

.quest-log-entry.player .quest-log-text {
  font-family: var(--font-body);
  font-size: 0.86rem;
  color: #4a3020;
}

.quest-log-text mark,
.quest-log-scene mark,
.quest-log-marker mark {
  background: rgba(212, 168, 75, 0.35);
  color: inherit;
  border-radius: 2px;
  padding: 0 0.1em;
}

.quest-log-text mark.is-current,
.quest-log-scene mark.is-current,
.quest-log-marker mark.is-current,
[data-ql-hit].is-current {
  background: rgba(212, 168, 75, 0.72);
  box-shadow: 0 0 0 1px rgba(106, 58, 18, 0.45);
}

.quest-log-list .empty-hint {
  color: #6a5840;
}

/* Token usage modal — capped height + internal scroll */
.tokens-modal {
  width: min(460px, 100%);
  max-width: 100%;
  max-height: min(88dvh, 88vh, 720px);
  box-sizing: border-box;
  overflow: hidden;
  text-align: left;
  background: var(--cw-modal-surface);
  color: var(--cw-parchment);
  display: flex;
  flex-direction: column;
}

.tokens-modal .dice-header {
  justify-content: flex-start;
  flex-shrink: 0;
}

.tokens-modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding-right: 0.15rem;
  margin-bottom: 0.35rem;
}

.tokens-modal-footer {
  flex-shrink: 0;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.15rem;
}

.tokens-summary-grid {
  margin-bottom: 0.85rem;
}

.tokens-summary-card strong {
  font-size: 1.25rem;
}

.tokens-summary-card.all-users,
#tokensAccountSummary .token-stat {
  border-color: rgba(212, 168, 75, 0.4);
  background: rgba(42, 32, 18, 0.45);
}

.token-stat .token-sub {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--cw-muted);
  overflow-wrap: anywhere;
}

.tokens-users-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin: 0 0 0.5rem;
  min-height: 2rem;
}

.tokens-user-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  width: 100%;
  padding: 0.7rem 0.85rem;
  background: var(--cw-panel-2);
  border: 1px solid var(--cw-border);
  border-radius: 8px;
  color: var(--cw-parchment);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  box-sizing: border-box;
}

.tokens-user-row:hover,
.tokens-user-row:focus-visible {
  border-color: rgba(212, 168, 75, 0.55);
  background: rgba(42, 32, 18, 0.55);
  box-shadow: 0 0 0 1px rgba(212, 168, 75, 0.2);
  outline: none;
}

.tokens-user-row .tokens-user-name {
  font-family: var(--font-display);
  font-size: 1rem;
  color: var(--cw-gold);
  font-weight: 600;
}

.tokens-user-row .tokens-user-meta {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--cw-muted);
}

.tokens-users-empty {
  color: var(--cw-muted);
  font-size: 0.85rem;
  padding: 0.5rem 0.15rem;
}

.tokens-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
  margin: 0 0 0.75rem;
  min-width: 0;
}

.token-stat {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.7rem 0.75rem;
  background: var(--cw-panel-2);
  border: 1px solid var(--cw-border);
  border-radius: 8px;
  min-width: 0;
  box-sizing: border-box;
}

.token-stat .token-label {
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--cw-muted);
}

.token-stat strong {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  color: var(--cw-gold);
  font-weight: 600;
  overflow-wrap: anywhere;
}

.token-stat.cost strong {
  color: #8fd4a8;
}

.token-stat-readout {
  cursor: default;
  user-select: text;
  background: rgba(18, 28, 22, 0.45);
  border-style: dashed;
}

.token-stat.total-cost {
  grid-column: 1 / -1;
  border-color: rgba(143, 212, 168, 0.35);
  background: rgba(24, 42, 30, 0.35);
}

.token-stat.total-cost strong {
  font-size: 1.35rem;
  color: #a8e6bc;
}

.tokens-turn-cost-grid {
  margin-bottom: 0.35rem;
}

.tokens-turn-hint {
  color: var(--cw-muted);
}

.tokens-pricing-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0.5rem;
  align-items: end;
  margin-bottom: 0.5rem;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}

.tokens-pricing-row .model-field {
  margin-bottom: 0;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}

.tokens-pricing-row .model-field input {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 2.6rem;
  box-sizing: border-box;
  font-size: 1rem;
}

.tokens-save-rates {
  display: block;
  width: 100%;
  box-sizing: border-box;
  margin: 0 0 0.85rem;
  padding: 0.65rem 0.85rem;
}

.tokens-cost-grid {
  margin-bottom: 0.75rem;
}

.tokens-modal .model-actions {
  width: 100%;
  box-sizing: border-box;
}

.tokens-modal .model-actions .btn-primary,
.tokens-modal .model-actions .btn-ghost {
  min-width: 0;
  box-sizing: border-box;
}

/* WM model picker — pin active/default status; list uses remaining height and scrolls */
.model-modal {
  width: min(520px, 100%);
  max-height: min(88vh, 720px);
  display: flex;
  flex-direction: column;
  background: var(--cw-modal-surface);
  color: var(--cw-parchment);
  text-align: left;
}

#modelBackdrop .model-modal {
  width: min(560px, 100%);
  max-width: 100%;
  max-height: min(88dvh, 88vh, 760px);
  min-height: 0;
  overflow: hidden;
  box-sizing: border-box;
}

#modelBackdrop .model-modal .dice-header,
#modelBackdrop .model-modal .dice-sub,
#modelBackdrop .model-modal .model-status,
#modelBackdrop .model-modal .model-custom-panel,
#modelBackdrop .model-modal .model-custom-row,
#modelBackdrop .model-modal .model-actions {
  flex-shrink: 0;
}

#modelBackdrop .model-modal .model-status {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

#modelBackdrop .model-modal .model-status-line {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.12rem;
  margin-bottom: 0.4rem;
}

#modelBackdrop .model-modal .model-status-value {
  color: var(--cw-parchment);
  font-weight: 600;
  overflow-wrap: anywhere;
  word-break: break-word;
}

#modelBackdrop .model-modal .model-status-id {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--cw-muted);
  overflow-wrap: anywhere;
  word-break: break-all;
}

.model-option.custom-option {
  border-color: rgba(212, 168, 75, 0.4);
  background: rgba(28, 22, 14, 0.55);
}

.model-badge.custom-badge {
  color: var(--cw-gold);
  border-color: rgba(212, 168, 75, 0.5);
  background: rgba(212, 168, 75, 0.12);
}

.model-custom-panel {
  margin: 0 0 0.75rem;
  padding: 0.75rem 0.8rem;
  border: 1px solid rgba(212, 168, 75, 0.35);
  border-radius: 10px;
  background: rgba(16, 14, 10, 0.65);
}

.model-custom-panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem 0.75rem;
  margin-bottom: 0.35rem;
}

.model-custom-panel-head .effects-heading {
  margin: 0;
}

.model-custom-panel-head #modelCustomBack {
  flex: 0 0 auto;
  border-color: rgba(212, 168, 75, 0.45);
  color: var(--cw-gold);
}

/* Segmented provider picker (radios are invisible under global appearance:none). */
.model-provider-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin: 0 0 0.75rem;
}

.model-provider-label {
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--cw-muted);
}

.model-provider-seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
}

.model-provider-btn {
  appearance: none;
  -webkit-appearance: none;
  margin: 0;
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--cw-border);
  background: var(--cw-panel-2);
  color: var(--cw-parchment-dim);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s, color 0.12s, box-shadow 0.12s;
}

.model-provider-btn:hover {
  border-color: var(--cw-gold-dim);
  color: var(--cw-parchment);
}

.model-provider-btn.active,
.model-provider-btn[aria-pressed="true"] {
  border-color: var(--cw-gold);
  background: linear-gradient(180deg, rgba(212, 168, 75, 0.22), rgba(138, 101, 32, 0.18));
  color: var(--cw-parchment);
  box-shadow: inset 0 0 0 1px rgba(212, 168, 75, 0.35), var(--cw-glow);
}

.model-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.5rem;
  font-size: 0.75rem;
  color: var(--cw-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.model-field input,
.model-field select,
.model-field textarea {
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--cw-border);
  background: var(--cw-bg);
  color: var(--cw-text);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  text-transform: none;
  letter-spacing: 0;
}

.model-field input::placeholder,
.model-field textarea::placeholder {
  color: var(--cw-muted);
  opacity: 0.9;
}

.model-field input:focus,
.model-field select:focus,
.model-field textarea:focus {
  outline: none;
  border-color: var(--cw-gold-dim);
  box-shadow: 0 0 0 2px rgba(212, 168, 75, 0.12);
}

.model-custom-scope {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.35rem;
}

.model-status {
  margin: 0 0 0.65rem;
  font-size: 0.8rem;
  color: var(--cw-muted);
  line-height: 1.4;
}

.model-status strong {
  color: var(--cw-parchment-dim);
  font-weight: 600;
}

.model-status .model-msg {
  margin-top: 0.35rem;
  color: var(--cw-gold);
}

.model-status .model-msg.error {
  color: var(--cw-danger);
}

.model-list {
  flex: 1 1 auto;
  overflow-y: auto;
  max-height: min(48vh, 360px);
  margin: 0 0 0.75rem;
  padding: 0.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  border: 1px solid var(--cw-border);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.18);
}

/* Picker list: use leftover modal height so every catalog row is reachable */
#modelBackdrop .model-modal .model-list {
  flex: 1 1 auto;
  min-height: 8rem;
  max-height: none;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* Make room for the provider form when Custom panel is open */
.model-modal:has(#modelCustomPanel:not([hidden])) .model-list {
  max-height: min(28vh, 200px);
  flex: 0 1 auto;
}

#modelBackdrop .model-modal:has(#modelCustomPanel:not([hidden])) .model-list {
  min-height: 5.5rem;
  max-height: none;
  flex: 1 1 auto;
}

.model-option {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  width: 100%;
  padding: 0.65rem 0.8rem;
  background: var(--cw-panel-2);
  border: 1px solid var(--cw-border);
  border-radius: 8px;
  color: var(--cw-parchment);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.model-option:hover,
.model-option:focus-visible {
  border-color: var(--cw-gold-dim);
  background: rgba(212, 168, 75, 0.08);
  outline: none;
}

.model-option.active {
  border-color: var(--cw-gold);
  box-shadow: 0 0 0 1px rgba(212, 168, 75, 0.35);
  background: rgba(212, 168, 75, 0.1);
}

.model-option .model-option-label {
  font-weight: 600;
  color: var(--cw-parchment);
  font-size: 0.9rem;
  line-height: 1.3;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.model-option .model-option-id {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--cw-muted);
  word-break: break-all;
}

.model-option .model-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.15rem;
}

.model-badge {
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.12rem 0.4rem;
  border-radius: 999px;
  border: 1px solid var(--cw-border);
  color: var(--cw-muted);
}

.model-badge.active-badge {
  color: var(--cw-gold);
  border-color: rgba(212, 168, 75, 0.55);
  background: rgba(212, 168, 75, 0.12);
}

.model-badge.default-badge {
  color: var(--cw-copper);
  border-color: rgba(196, 140, 90, 0.5);
}

.model-option-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.4rem;
  width: 100%;
}

.model-option-actions .btn-tiny {
  appearance: none;
  border: 1px solid var(--cw-border);
  background: rgba(0, 0, 0, 0.25);
  color: var(--cw-parchment-dim);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.28rem 0.55rem;
  border-radius: 6px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.model-option-actions .btn-tiny:hover {
  border-color: var(--cw-gold-dim);
  color: var(--cw-gold);
  background: rgba(212, 168, 75, 0.1);
}

.model-option-actions .btn-tiny.primary {
  border-color: rgba(212, 168, 75, 0.45);
  color: var(--cw-gold);
}

.model-option-actions .btn-tiny.danger {
  border-color: rgba(212, 92, 92, 0.45);
  color: var(--cw-danger);
}

.model-option-actions .btn-tiny.danger:hover {
  border-color: var(--cw-danger);
  color: #f0c0c0;
  background: rgba(212, 92, 92, 0.12);
}

.model-custom-row {
  display: flex;
  gap: 0.45rem;
  margin-bottom: 0.75rem;
}

.model-custom-row input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  border: 1px solid var(--cw-border);
  background: var(--cw-panel-2);
  color: var(--cw-parchment);
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

.model-custom-row input:focus {
  outline: none;
  border-color: var(--cw-gold-dim);
}

.model-custom-row .btn-primary {
  flex: 0 0 auto;
  padding: 0.55rem 0.85rem;
}

.model-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}

.model-actions .btn-ghost {
  flex: 1 1 auto;
  min-width: 7rem;
}

.model-actions .btn-ghost.active-custom {
  border-color: var(--cw-gold);
  color: var(--cw-parchment);
  box-shadow: inset 0 0 0 1px rgba(212, 168, 75, 0.35);
}

/* Rest choice (DM-labeled) */
.rest-modal {
  text-align: left;
  background: var(--cw-modal-surface);
  color: var(--cw-parchment);
}

.rest-modal .dice-header {
  justify-content: flex-start;
}

.rest-modal .dice-sub {
  text-align: left;
  color: var(--cw-parchment-dim);
  line-height: 1.45;
}

.rest-choices {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-bottom: 0.85rem;
}

.rest-choice {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
  width: 100%;
  padding: 0.75rem 0.9rem;
  background: var(--cw-panel-2);
  border: 1px solid var(--cw-border);
  border-radius: 8px;
  color: var(--cw-parchment);
  text-align: left;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.rest-choice strong {
  font-family: var(--font-display);
  color: var(--cw-gold);
  font-size: 0.95rem;
}

.rest-choice span {
  font-size: 0.8rem;
  color: var(--cw-muted);
  line-height: 1.35;
}

.rest-choice:hover {
  border-color: var(--cw-gold-dim);
  background: #16130f;
  box-shadow: inset 3px 0 0 var(--cw-gold);
}

.rest-cancel {
  width: 100%;
}

/* Save / Load dialog */
.save-load-modal {
  width: min(560px, 100%);
  max-height: min(85vh, 720px);
  overflow-y: auto;
  background: var(--cw-modal-surface);
  color: var(--cw-parchment);
  text-align: left;
}

.save-load-section {
  margin-bottom: 1rem;
}

.save-load-list {
  max-height: 280px;
  overflow-y: auto;
  overflow-x: hidden;
}

.save-load-list li {
  flex-wrap: wrap;
}

.save-load-list .btn-primary,
.save-row-actions .btn-primary {
  padding: 0.4rem 0.75rem;
  font-size: 0.72rem;
}

.save-list li {
  gap: 0.65rem;
}

.empty-hint {
  color: var(--cw-muted);
  font-style: italic;
  padding: 1rem 0;
}

/* —— Responsive: tablet / narrow laptop —— */
@media (max-width: 960px) {
  .play {
    grid-template-columns: minmax(240px, 34%) 1fr;
  }

  .topbar-meta {
    gap: 0.5rem;
    font-size: 0.75rem;
  }

  .brand-text h1 {
    font-size: 0.95rem;
  }
}

/* —— Responsive: tablet portrait / large phone landscape ——
   Desktop (≥861px) keeps the side-by-side grid unchanged.
   Mobile uses a vertical flex stack so sheet never sits under narration. */
@media (max-width: 860px) {
  html,
  body {
    /* Device mode: +7% over desktop base (not the old smaller 14px) */
    font-size: var(--cw-font-size-mobile);
    height: auto;
    min-height: 100dvh;
    max-height: none;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  #app {
    height: auto;
    min-height: 100dvh;
    max-height: none;
    overflow: visible;
  }

  /* Keep the document at the topbar until the user scrolls. Portrait / scene
     text / log growth must not overflow-anchor the viewport down to Scene. */
  #hub,
  #play,
  .scene-box,
  .log-scroll {
    overflow-anchor: none;
  }

  .topbar {
    --cw-hdr-btn-gap: 0.3rem;
    --cw-hdr-rail: 8.25rem;
    --cw-hdr-layer-shift: 20px;
    flex-wrap: wrap;
    align-items: flex-start;
    padding-top: 0.5rem;
    padding-bottom: var(--cw-hdr-btn-gap);
    padding-right: max(calc(var(--cw-hdr-rail) + 0.75rem), env(safe-area-inset-right, 0px));
    min-height: calc(
      var(--cw-hdr-layer-shift) + 0.5rem + 1.55rem + var(--cw-hdr-btn-gap) +
        1.55rem + var(--cw-hdr-btn-gap)
    );
    position: relative;
    z-index: 20;
    overflow: visible;
  }

  /* Invisible header layer — buttons sit on top of this rail */
  .topbar::before {
    content: "";
    position: absolute;
    top: var(--cw-hdr-layer-shift);
    right: 0;
    bottom: 0;
    width: var(--cw-hdr-rail);
    z-index: 1;
    pointer-events: none;
    background: transparent;
  }

  .topbar-meta {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
    max-width: none;
  }

  .topbar-meta .model-chip {
    max-width: 100%;
  }

  .topbar-meta .model-chip:has(#questLogBtn),
  .topbar-account {
    position: absolute;
    right: max(1rem, env(safe-area-inset-right, 0px));
    z-index: 2;
    margin-left: 0;
    width: auto;
    box-sizing: border-box;
  }

  .topbar-meta .model-chip:has(#questLogBtn) {
    top: calc(var(--cw-hdr-layer-shift) + 0.5rem);
    display: flex;
    justify-content: flex-end;
  }

  .topbar-meta .model-chip:has(#questLogBtn) .questlog-btn {
    width: auto;
    margin-left: 0;
    text-align: center;
    white-space: nowrap;
  }

  .topbar-account {
    top: calc(var(--cw-hdr-layer-shift) + 0.5rem + 1.55rem + var(--cw-hdr-btn-gap));
    justify-content: flex-end;
    width: auto;
  }

  .topbar-account .topbar-chip {
    width: auto;
    margin-left: 0;
    text-align: center;
    white-space: nowrap;
  }

  /* Vertical stack — header + play scroll as one page */
  .play {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow: visible;
    grid-template-columns: unset;
    grid-template-rows: unset;
  }

  /* Character column: full natural height, never shrink under the log */
  .pane-left {
    display: flex;
    flex-direction: column;
    flex: 0 0 auto;
    width: 100%;
    min-height: min-content;
    height: auto;
    max-height: none;
    overflow: visible;
    border-right: none;
    border-bottom: 1px solid var(--cw-border);
    padding: 0.85rem 0.9rem 1.25rem;
    position: relative;
    z-index: 2;
  }

  .scene-box {
    display: block;
    flex: 0 0 auto;
    margin-top: 0.85rem;
    margin-bottom: 0.25rem;
    padding: 0.8rem 0.85rem 1rem;
    font-size: 0.9rem;
    line-height: 1.55;
    height: auto;
    max-height: none;
    overflow: visible;
  }

  .scene-box .scene-text,
  .scene-box #sceneText {
    display: block;
    margin: 0;
    line-height: 1.55;
    height: auto;
    max-height: none;
    overflow: visible;
    white-space: normal;
    overflow-wrap: break-word;
  }

  /* Narration + actions sit BELOW the sheet, not on top of it */
  .pane-right {
    display: flex;
    flex-direction: column;
    flex: 0 0 auto;
    width: 100%;
    min-height: 55vh;
    height: auto;
    max-height: none;
    overflow: visible;
    position: relative;
    z-index: 1;
  }

  .pane-right {
    min-height: 0;
  }

  .dm-pane {
    display: flex;
    flex-direction: column;
    flex: 0 0 auto;
    min-height: 0;
    height: auto;
    max-height: none;
    overflow: visible;
  }

  .log-scroll {
    flex: 0 0 auto;
    min-height: 8rem;
    max-height: 32vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .actions-dock {
    display: flex;
    flex-direction: column;
    flex: 0 0 auto;
    min-height: 0;
    max-height: none;
    overflow: visible;
  }

  /* Powers reminder: always full-width under title on phones */
  .actions-available-powers {
    font-size: 0.78rem;
    color: var(--cw-parchment, #e8dcc4);
    max-height: 5.5em;
    padding: 0.2rem 0 0.35rem;
  }

  .action-grid {
    max-height: none;
    overflow: visible;
  }

  /* Expand controls visible on phone / tablet stack */
  .panel-expand-btn {
    display: inline-flex;
  }

  /* Full-viewport reading mode for narrative.
   * Header + combat tracker are hidden via body.panel-fullscreen —
   * panel owns the full screen even mid-fight. */
  .dm-pane.is-expanded {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    inset: 0 !important;
    z-index: 10000 !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 100dvh !important;
    height: 100vh !important;
    max-height: 100dvh !important;
    min-height: 0 !important;
    flex: none !important;
    margin: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding-top: max(0.35rem, env(safe-area-inset-top, 0px));
    padding-bottom: max(0.35rem, env(safe-area-inset-bottom, 0px));
    padding-left: max(0.35rem, env(safe-area-inset-left, 0px));
    padding-right: max(0.35rem, env(safe-area-inset-right, 0px));
    background: var(--cw-bg);
    /* Escape parent overflow / stacking (combat layout, pane-right flex) */
    transform: translateZ(0);
    visibility: visible !important;
    pointer-events: auto !important;
    display: flex !important;
    flex-direction: column;
  }

  /* Combat tracker is a child of dm-pane — never show it while expanded */
  .dm-pane.is-expanded > .combat-tracker {
    display: none !important;
  }

  .dm-pane.is-expanded .log-scroll {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 0.75rem 1rem 1.25rem;
  }

  /* Sticky head + large tappable collapse so it never scrolls off-screen */
  .dm-pane.is-expanded .panel-head-narrative {
    position: sticky;
    top: 0;
    z-index: 5;
    flex-shrink: 0;
    background: var(--cw-bg-elevated, #16120c);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.55);
  }

  .dm-pane.is-expanded .panel-expand-btn {
    width: 2.75rem;
    min-width: 2.75rem;
    min-height: 2.75rem;
    margin: 0.35rem 0.45rem 0.35rem 0;
    font-size: 1.15rem;
    border-color: var(--cw-gold);
    color: var(--cw-gold);
    background: rgba(212, 168, 75, 0.14);
  }

  .dm-pane.is-expanded::before {
    display: none;
  }

  .portrait-frame {
    --portrait-max-h: min(36vh, 18rem);
    aspect-ratio: 4 / 3;
    width: min(100%, calc(var(--portrait-max-h) * 4 / 3), 26rem);
    max-width: 100%;
    max-height: var(--portrait-max-h);
    height: auto;
    flex: 0 0 auto;
    margin-inline: auto;
  }

  .toolbar {
    flex: 0 0 auto;
  }

  .toolbar-group {
    grid-template-columns: repeat(4, 1fr);
  }

  .hub {
    padding: 1.25rem 1rem 2rem;
  }

  .hub-card {
    padding: 1.25rem;
  }

  .modal-backdrop,
  .dice-backdrop {
    padding: 0.75rem;
    align-items: flex-end;
  }

  .modal,
  .dice-modal {
    width: 100%;
    max-width: 100%;
    max-height: min(92dvh, 92vh);
    border-radius: 8px 8px 4px 4px;
    min-height: 0;
  }

  /* Keep WM picker header + active model on-screen; list scrolls inside */
  #modelBackdrop {
    align-items: flex-start;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  #modelBackdrop .model-modal {
    width: 100%;
    max-height: min(92dvh, 92vh);
  }

  .dice-backdrop:has(.quest-log-modal) {
    align-items: stretch;
    overflow: hidden;
    padding-bottom: max(0.75rem, env(safe-area-inset-bottom, 0px));
  }

  .quest-log-modal.dice-modal {
    height: 100%;
    max-height: none;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding-bottom: 1rem;
  }

  .quest-log-doc-nav {
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: stretch;
    gap: 0.4rem;
  }

  .quest-log-doc-nav h2 {
    flex: 1 0 100%;
    order: -1;
    font-size: 1.05rem;
    line-height: 1.25;
    white-space: normal;
    overflow: hidden;
    text-overflow: unset;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
  }

  .quest-log-doc-btn {
    flex: 1 1 0;
    width: auto;
    min-width: 2.75rem;
    height: 2.75rem;
    font-size: 1.55rem;
  }

  .quest-log-jump {
    width: 2.75rem;
    height: 2.75rem;
    font-size: 1.2rem;
  }

  .quest-log-search-row {
    flex-direction: column;
    align-items: stretch;
  }

  .quest-log-search-wrap {
    flex: 1 1 auto;
    width: 100%;
  }

  .quest-log-search {
    min-height: 44px;
    font-size: 1rem;
  }

  .quest-log-find {
    width: 100%;
    justify-content: stretch;
    gap: 0.45rem;
  }

  .quest-log-find-count {
    flex: 1 1 auto;
    min-width: 0;
    text-align: center;
    font-size: 0.85rem;
  }

  .quest-log-find-btn {
    flex: 1 1 0;
    min-height: 44px;
    padding: 0.55rem 0.75rem;
    font-size: 0.85rem;
  }

  .quest-log-list {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
  }

  .modal-body {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
  }

  /* Full-width "What do you do?" with Send under it */
  .compose {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    flex-wrap: nowrap;
  }

  .compose input {
    width: 100%;
    min-width: 0;
    min-height: 48px;
    flex: none;
    box-sizing: border-box;
  }

  .compose .btn-primary,
  .compose #btnSend {
    width: 100%;
    min-height: 48px;
    flex: none;
    box-sizing: border-box;
  }

  .action-item {
    max-width: 100%;
  }

  .tool-btn {
    min-height: 44px;
    padding: 0.45rem 0.25rem;
  }
}

/* —— Responsive: phones —— */
@media (max-width: 560px) {
  .brand-mark {
    width: 36px;
    height: 36px;
  }

  .brand-text h1 {
    font-size: 0.85rem;
    letter-spacing: 0.05em;
  }

  .brand-text p {
    font-size: 0.62rem;
  }

  button.model-link,
  button.questlog-btn,
  button.tokens-btn,
  button.exit-btn,
  button.topbar-chip {
    font-size: 0.62rem;
    padding: 0.28rem 0.45rem;
  }

  .stat-grid {
    grid-template-columns: 1fr 1fr;
  }

  .toolbar {
    gap: 0.55rem;
  }

  .toolbar-group {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.35rem;
  }

  .portrait-frame {
    /* Phone: natural 4:3, not a short cropped strip */
    --portrait-max-h: min(32vh, 15rem);
    aspect-ratio: 4 / 3;
    width: min(100%, calc(var(--portrait-max-h) * 4 / 3));
    max-width: 100%;
    max-height: var(--portrait-max-h);
    height: auto;
    margin-inline: auto;
  }

  .hero-name {
    font-size: 1.1rem;
    margin-top: 0.65rem;
  }

  .scene-box {
    padding: 0.85rem 0.8rem 1.1rem;
    font-size: 0.9rem;
    line-height: 1.55;
  }

  .pane-left {
    padding-bottom: 1.35rem;
  }

  .dm-pane {
    flex: 0 0 auto;
    height: auto;
    max-height: none;
    min-height: 0;
  }

  .actions-dock {
    flex: 0 0 auto;
    max-height: none;
    min-height: 0;
  }

  .log-scroll {
    font-size: 0.9rem;
  }

  .scene-header {
    flex-wrap: wrap;
    gap: 0.35rem;
    font-size: 0.75rem;
  }

  .tokens-pricing-row {
    grid-template-columns: 1fr;
  }

  .model-custom-row {
    flex-direction: column;
  }

  .model-custom-row .btn-primary {
    width: 100%;
  }

  .save-list li,
  .save-load-list li {
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
  }

  .campaign-block .campaign-header {
    flex-direction: column;
    align-items: stretch;
  }

  .campaign-block .campaign-saves {
    padding-left: 0.55rem;
  }

  .save-list .save-info,
  .save-load-list .save-info {
    width: 100%;
  }

  .save-list .save-meta,
  .save-load-list .save-meta {
    white-space: normal;
  }

  /* Enter + Delete sit in one full-width row inside the card */
  .save-list .save-row-actions,
  .save-load-list .save-row-actions {
    width: 100%;
    max-width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: stretch;
    gap: 0.45rem;
  }

  .save-list .save-row-actions .btn-primary,
  .save-list .save-row-actions .drop-btn,
  .save-load-list .save-row-actions .btn-primary,
  .save-load-list .save-row-actions .drop-btn {
    flex: 1 1 calc(50% - 0.25rem);
    min-width: 6.5rem;
    width: auto;
    max-width: 100%;
    text-align: center;
    justify-content: center;
  }

  /* Solo Enter (autosave) still full width */
  .save-list .save-row-actions .btn-primary:only-child,
  .save-load-list .save-row-actions .btn-primary:only-child {
    flex: 1 1 100%;
  }

  .item-row {
    flex-wrap: wrap;
  }

  /* Portrait / narrow: stack label above Share/Drop so taps hit the name,
     not the action buttons (width:100% used to overlay the label). */
  .item-row-head {
    flex-direction: column;
    align-items: stretch;
    gap: 0.4rem;
  }

  .item-label-toggle {
    width: 100%;
    flex: 1 1 auto;
    min-width: 0;
  }

  .item-actions {
    width: 100%;
    justify-content: flex-end;
    flex-wrap: wrap;
    min-width: 0;
    position: relative;
    z-index: 0;
  }

  .item-detail {
    width: 100%;
  }
}

/* Touch / coarse pointer: same +7% type scale when not already under 860px */
@media (hover: none) and (pointer: coarse) {
  html,
  body {
    font-size: var(--cw-font-size-mobile);
  }

  .action-btn,
  .action-copy,
  .tool-btn,
  .btn-primary,
  .btn-ghost,
  .share-btn,
  .drop-btn,
  .item-label-toggle,
  .quest-log-find-btn,
  .quest-log-doc-btn,
  .quest-log-jump,
  .model-option-actions .btn-tiny {
    min-height: 44px;
  }

  .action-copy {
    min-width: 2.5rem;
  }
}

/* Prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* —— Auth / Account (bible v3) —— */
.login-card .login-form {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-top: 0.75rem;
}

.login-card input {
  font-size: 16px; /* mobile: avoid iOS zoom */
  min-height: 44px;
  background: rgba(255, 248, 230, 0.55);
  border: 1px solid rgba(90, 62, 28, 0.35);
  border-radius: 3px;
  padding: 0.55rem 0.75rem;
  color: var(--cw-paper-ink);
}

.login-card.scroll-panel .model-field span,
.login-card.scroll-panel label span,
.login-card.scroll-panel label {
  color: #e8dcc4;
}

.login-card input::placeholder {
  color: var(--cw-muted);
  opacity: 0.9;
}

.login-card input:focus {
  outline: none;
  border-color: var(--cw-gold-dim);
  box-shadow: 0 0 0 2px rgba(212, 168, 75, 0.15);
}

/* Password reveal on login — side-by-side flex (never absolute over the input).
   Overlay buttons fail hit-testing on many mobile browsers. */
.login-pass-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.login-pass-field > label {
  display: block;
}

.password-field {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 0.45rem;
  width: 100%;
}

.password-field input#loginPass,
.password-field input {
  flex: 1 1 auto;
  min-width: 0;
  width: auto;
  box-sizing: border-box;
  /* Don't inherit .model-field uppercase onto revealed password text */
  text-transform: none;
  letter-spacing: 0;
}

.password-toggle {
  flex: 0 0 auto;
  align-self: stretch;
  min-width: 4.5rem;
  min-height: 44px;
  padding: 0 0.75rem;
  margin: 0;
  border: 1px solid rgba(90, 62, 28, 0.35);
  border-radius: 3px;
  background: rgba(90, 62, 28, 0.12);
  color: #6a4a18;
  cursor: pointer;
  font-family: var(--font-body, inherit);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  line-height: 1.2;
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(212, 168, 75, 0.25);
  -webkit-user-select: none;
  user-select: none;
}

.password-toggle:hover,
.password-toggle:focus-visible {
  border-color: var(--cw-gold-dim);
  background: rgba(212, 168, 75, 0.12);
  outline: none;
}

.password-toggle:active {
  background: rgba(212, 168, 75, 0.22);
}

.password-toggle[aria-pressed="true"] {
  border-color: var(--cw-gold-dim);
  color: var(--cw-parchment, #e8dfc8);
}

.hub-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.75rem 0 1rem;
}

/* Account + Admin chips — side by side in the top header */
.topbar {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

@media (max-width: 860px) {
  /* Later .topbar { align-items: center } must not drop the title into the buttons */
  .topbar {
    align-items: flex-start;
  }
}

.topbar-meta {
  flex: 1 1 auto;
  min-width: 0;
}

.topbar-account {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.4rem;
  flex: 0 0 auto;
  margin-left: auto;
}

.topbar-account[hidden],
.topbar-account.hidden,
body:not(.cw-authed) .topbar-account {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

.topbar-chip {
  appearance: none;
  flex-shrink: 0;
  margin-left: 0.15rem;
  padding: 0.18rem 0.5rem;
  border-radius: 6px;
  border: 1px solid rgba(212, 168, 75, 0.4);
  background: rgba(212, 168, 75, 0.1);
  color: var(--cw-gold);
  font-family: var(--font-display);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  white-space: nowrap;
  line-height: 1.2;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.topbar-chip:hover,
.topbar-chip:focus-visible {
  background: rgba(212, 168, 75, 0.2);
  border-color: var(--cw-gold);
  color: var(--cw-parchment);
  outline: none;
}

.topbar-chip.admin-chip {
  border-color: rgba(212, 168, 75, 0.4);
  color: var(--cw-gold);
}

/* Legacy class hooks (if any leftover markup) */
.account-dock {
  display: none !important;
}

.campaign-wizard-modal {
  max-width: min(640px, 96vw);
  max-height: min(88vh, 900px);
  max-height: min(88dvh, 900px);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 1rem;
  box-sizing: border-box;
  background: var(--cw-modal-surface);
  color: var(--cw-parchment);
}

.campaign-wizard-modal .model-list {
  max-height: min(50vh, 420px);
}

.campaign-wizard-modal .model-list.is-weaving {
  opacity: 0.45;
  pointer-events: none;
}

#ncReimagine:disabled,
#forkReimagine:disabled,
#ncReimagine.is-busy,
#forkReimagine.is-busy {
  opacity: 0.55;
  cursor: wait;
  filter: grayscale(0.35);
}

.nc-step-indicator {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
  color: var(--cw-gold);
  font-family: var(--font-display);
  letter-spacing: 0.04em;
}

.nc-confirm-summary {
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--cw-border);
  border-radius: 10px;
  background: var(--cw-bg);
  margin-bottom: 0.75rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

.nc-hero .model-field {
  margin-top: 0.35rem;
}

/* Gender + Age side by side under Name */
.nc-gender-age-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
  align-items: flex-end;
  margin-top: 0.35rem;
}

.nc-gender-age-row .model-field {
  margin-top: 0;
  flex: 1 1 8rem;
  min-width: 7rem;
}

.nc-gender-age-row .nc-age-field {
  flex: 0 1 9.5rem;
  max-width: 11rem;
}

.nc-age-input-wrap {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
}

.nc-gender-age-row .nc-h-age {
  flex: 1 1 auto;
  min-width: 3.5rem;
  max-width: 5.5rem;
  box-sizing: border-box;
}

.nc-age-unit {
  color: var(--cw-muted, var(--cw-parchment));
  opacity: 0.85;
  font-size: 0.9rem;
  font-family: var(--font-body, inherit);
  white-space: nowrap;
  user-select: none;
}

/* Player: read-only model label (no click picker) */
.model-label-static {
  color: var(--cw-parchment);
  font-family: var(--font-display);
  font-size: 0.85rem;
  letter-spacing: 0.02em;
}

.model-readonly {
  opacity: 0.9;
  cursor: default;
}

/* Login-first: keep hub/play fully out of layout when hidden */
#hub[hidden],
#play[hidden],
#login[hidden] {
  display: none !important;
}

/* Character creation: defines under dropdowns (wrap + scroll inside modal) */
.nc-hero {
  margin: 0.65rem 0;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--cw-border);
  border-radius: 10px;
  background: var(--cw-bg);
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

.nc-hero-title {
  display: block;
  color: var(--cw-gold);
  font-family: var(--font-display);
  margin-bottom: 0.35rem;
  letter-spacing: 0.03em;
}

.nc-hero .model-field select {
  width: 100%;
  max-width: 100%;
  font-size: 0.9rem;
}

/* Scrollable define lists — stay inside modal; word-wrap; 2 line gaps */
.nc-define-list {
  display: block;
  max-height: min(11rem, 28vh);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  margin: 0.35rem 0 0.85rem;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--cw-border);
  border-radius: 8px;
  background: var(--cw-panel-2);
  box-sizing: border-box;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.nc-define-item {
  display: block;
  /* Two full line spaces between defines (line-height 1.45 × 2 ≈ 2.9em gap after each) */
  margin: 0 0 2.9em;
  padding: 0;
  max-width: 100%;
  box-sizing: border-box;
}

.nc-define-item:last-child {
  margin-bottom: 0.35em;
}

.nc-define-name {
  display: block;
  color: var(--cw-gold);
  font-family: var(--font-display);
  font-size: 0.82rem;
  letter-spacing: 0.03em;
  margin: 0 0 0.35em;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.nc-define-text {
  margin: 0;
  padding: 0;
  color: var(--cw-parchment-dim);
  font-size: 0.8rem;
  font-style: normal;
  line-height: 1.45;
  white-space: normal;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  word-break: break-word;
  hyphens: auto;
}

.nc-define-item.is-selected {
  border-left: 2px solid var(--cw-gold);
  padding-left: 0.55rem;
  margin-left: -0.1rem;
}

.nc-define-item.is-selected .nc-define-name {
  color: var(--cw-parchment);
}

.nc-define-item.is-selected .nc-define-text {
  color: var(--cw-text);
}

/* Spell pick step (WM-forged catalog) */
.spell-picks-root {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-height: min(52vh, 420px);
  overflow-y: auto;
  padding-right: 0.25rem;
  margin-bottom: 0.5rem;
}

.spell-pick-hero {
  padding: 0.75rem 0.85rem;
  background: var(--cw-panel-2);
  border: 1px solid var(--cw-border);
  border-radius: 10px;
}

.spell-pick-hero h4 {
  margin: 0 0 0.35rem;
  font-family: var(--font-display);
  color: var(--cw-gold);
  font-size: 0.95rem;
}

.spell-pick-need {
  font-size: 0.78rem;
  color: var(--cw-muted);
  margin: 0 0 0.55rem;
}

.spell-pick-group {
  margin-bottom: 0.65rem;
}

.spell-pick-group strong {
  display: block;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--cw-gold-dim);
  margin-bottom: 0.35rem;
}

.spell-pick-option {
  display: flex;
  gap: 0.55rem;
  align-items: flex-start;
  padding: 0.45rem 0.4rem;
  margin: 0 0 0.35rem;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}

.spell-pick-option:hover {
  background: rgba(212, 168, 75, 0.06);
}

.spell-pick-option.is-selected {
  border-color: rgba(212, 168, 75, 0.45);
  background: rgba(212, 168, 75, 0.1);
}

.spell-pick-option input {
  margin-top: 0.2rem;
  flex-shrink: 0;
}

.spell-pick-body {
  flex: 1;
  min-width: 0;
}

.spell-pick-name {
  font-weight: 600;
  color: var(--cw-parchment);
  font-size: 0.9rem;
}

.spell-pick-meta {
  font-size: 0.72rem;
  color: var(--cw-gold-dim);
  font-family: var(--font-mono);
  margin: 0.15rem 0;
}

.spell-pick-desc {
  font-size: 0.8rem;
  color: var(--cw-muted);
  line-height: 1.45;
}

/* Rich milieu cards */
.milieu-card {
  text-align: left;
  width: 100%;
  margin-bottom: 0.75rem;
  padding: 0.85rem 1rem;
}

.milieu-card strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: var(--cw-gold);
  margin-bottom: 0.25rem;
}

.milieu-card .milieu-tagline {
  display: block;
  font-style: italic;
  color: var(--cw-parchment);
  font-size: 0.88rem;
  margin-bottom: 0.45rem;
  line-height: 1.4;
}

.milieu-card .milieu-desc {
  display: block;
  font-size: 0.8rem;
  color: var(--cw-muted);
  line-height: 1.5;
  margin-bottom: 0.45rem;
  white-space: pre-wrap;
}

.milieu-card .milieu-hook {
  display: block;
  font-size: 0.78rem;
  color: var(--cw-parchment-dim);
  line-height: 1.45;
  padding-top: 0.4rem;
  border-top: 1px solid var(--cw-border);
}

.milieu-card .milieu-hook-label {
  color: var(--cw-gold-dim);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  display: block;
  margin-bottom: 0.2rem;
}

/* Ability score rolling in character creation */
.nc-abilities {
  margin-top: 0.75rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--cw-border);
}

.nc-abilities-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.nc-abilities-head strong {
  color: var(--cw-gold);
  font-family: var(--font-display);
  font-size: 0.9rem;
}

.nc-ability-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.4rem;
  margin: 0.5rem 0;
}

.nc-ability-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.4rem 0.25rem;
  background: var(--cw-panel-2);
  border: 1px solid var(--cw-border);
  border-radius: 8px;
}

.nc-ab-label {
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  color: var(--cw-muted);
  font-weight: 600;
}

.nc-ab-score {
  font-size: 1.25rem;
  color: var(--cw-parchment);
  font-family: var(--font-display);
  line-height: 1.2;
}

.nc-ab-mod {
  font-size: 0.75rem;
  color: var(--cw-gold-dim);
  font-family: var(--font-mono);
}

.nc-roll-log,
.nc-final-scores {
  font-size: 0.75rem !important;
  margin: 0.25rem 0 !important;
  padding: 0.25rem 0 !important;
}

@media (max-width: 480px) {
  .nc-ability-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
