/* DWEngine — enchanted dark-fantasy tabletop (doc-ui VIS tokens) */
/* Pixel display uses DW Pixel Latin (latin-only). Cyrillic always paints with Manrope. */
@import url("fonts-pixel-latin.css");
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Manrope:wght@500;600;700;800&family=Source+Serif+4:opsz,wght@8..60,400;8..60,600;8..60,700&family=IBM+Plex+Mono:wght@400;500;600&display=swap");

:root {
  /* Palette aligned to doc-ui/design-tokens.json (fallback when tokens.css absent) */
  --ink: #090e14;
  --stone: #17212d;
  --ledge: #2a3948;
  --ledge-soft: rgba(42, 57, 72, 0.65);
  --parchment: #e9e2d5;
  --ash: #9aa8b5;
  --ember: #e88b43;
  --ember-soft: rgba(232, 139, 67, 0.14);
  --ember-glow: rgba(232, 139, 67, 0.35);
  --moss: #72a985;
  --moss-soft: rgba(114, 169, 133, 0.16);
  --blood: #c75b5b;
  --blood-soft: rgba(199, 91, 91, 0.16);
  --torch: #f6ad69;
  --shadow: 0 10px 28px rgba(0, 0, 0, 0.35);

  --bg: var(--ink);
  --surface: var(--stone);
  --border: var(--ledge);
  --text: var(--parchment);
  --muted: var(--ash);
  --accent: var(--ember);
  --ok: var(--moss);
  --warn: #d7a552;
  --danger: var(--blood);

  /* VIS-002: Inter UI · Source Serif narrative · pixel Latin display (Cyrillic → Manrope) */
  --font-ui: Inter, "IBM Plex Sans", system-ui, sans-serif;
  --font-narrative: "Source Serif 4", Georgia, serif;
  --font-display-cyrillic: Manrope, Inter, "IBM Plex Sans", system-ui, sans-serif;
  --font-display: "DW Pixel Latin", var(--font-display-cyrillic);
  --font-display-pixel: var(--font-display);
  --font-body: var(--font-ui);
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --radius: 6px;
  --radius-sm: 4px;
  --topbar-h: 56px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --pixel: 2px;
  --pixel-highlight: #3b4a5c;
  --pixel-shadow: #080c11;
  --pixel-panel: #111923;
}

* {
  box-sizing: border-box;
}

/* Prefer Manrope for Russian UI so display metrics stay consistent. */
html[lang="ru"] {
  --font-display: var(--font-display-cyrillic);
  --font-display-pixel: var(--font-display-cyrillic);
}

html[lang="ru"] .text-display,
html[lang="ru"] .play-hero,
html[lang="ru"] .brand-mark,
html[lang="ru"] .topbar-nav a,
html[lang="ru"] .panel-header h2,
html[lang="ru"] .workspace-panel-identity h2,
html[lang="ru"] .composer-modes > button,
html[lang="ru"] .workspace-launchers > button,
html[lang="ru"] .btn-accent,
html[lang="ru"] .btn-sm,
html[lang="ru"] .phase-pill,
html[lang="ru"] .status-pill,
html[lang="ru"] .play-steps,
html[lang="ru"] .play-steps li,
html[lang="ru"] .play-card h2,
html[lang="ru"] .field > span,
html[lang="ru"] label.field > span {
  font-family: var(--font-display-cyrillic);
  letter-spacing: 0.03em;
}

html {
  color-scheme: dark;
}

body {
  margin: 0;
  font-family: var(--font-body);
  background:
    radial-gradient(ellipse at 14% -8%, rgba(232, 139, 67, 0.07), transparent 48%),
    radial-gradient(ellipse at 92% 8%, rgba(111, 159, 191, 0.045), transparent 42%),
    radial-gradient(ellipse at 50% 120%, rgba(146, 119, 201, 0.04), transparent 50%),
    linear-gradient(180deg, #0f1720 0%, var(--ink) 38%, #070b10 100%);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  line-height: var(--line-height-normal, 1.4);
  font-size: var(--font-size-md, 16px);
  -webkit-font-smoothing: antialiased;
}

/*
 * VIS-003 / VIS-006: pixel display for short chrome only; grid texture stays
 * at ~3.5% so body/narrative contrast is not taxed.
 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: var(--texture-opacity, 0.035);
  background-image:
    linear-gradient(rgba(233, 226, 213, 0.55) 1px, transparent 1px),
    linear-gradient(90deg, rgba(233, 226, 213, 0.55) 1px, transparent 1px);
  background-size: 8px 8px;
  image-rendering: pixelated;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 30%, transparent 40%, rgba(0, 0, 0, 0.22) 100%);
  opacity: 0.85;
}

button,
input,
textarea,
select,
.panel,
.play-card,
.status-pill,
.phase-pill {
  border-radius: 0;
}

button,
.topbar-nav a,
.status-pill,
.phase-pill,
.play-step-num,
.play-card h2,
.field > span {
  font-family: var(--mono);
}

.panel-header h2 {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.narrative-prose,
.chat-msg.chat-narrator .chat-body,
.lede {
  font-family: var(--font-narrative);
  line-height: var(--line-height-narrative, 1.55);
  font-size: 1.05rem;
}

button,
.status-pill,
.phase-pill {
  letter-spacing: 0.025em;
}

a {
  color: var(--torch);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

a:hover {
  color: var(--ember);
}

:focus-visible {
  outline: 2px solid var(--ember);
  outline-offset: 2px;
}

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

.mono,
.text-mono,
.numeric {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

.text-display {
  font-family: var(--font-display);
  font-weight: 650;
  letter-spacing: 0.04em;
}

.text-ui {
  font-family: var(--font-ui, var(--font-body));
}

.text-narrative {
  font-family: var(--font-narrative);
  line-height: var(--line-height-narrative, 1.55);
}

.small {
  font-size: 0.8rem;
}

.mt {
  margin-top: 1.1rem;
}

/* ── Topbar ─────────────────────────────────────────────── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 1.1rem;
  min-height: var(--topbar-h);
  padding: 0.55rem 1.1rem;
  border-bottom: 1px solid var(--chrome-furniture-edge, var(--ledge));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.04),
    inset 0 -1px 0 rgba(0, 0, 0, 0.35),
    0 6px 18px rgba(0, 0, 0, 0.28);
  background:
    linear-gradient(180deg, rgba(20, 29, 40, 0.98), rgba(10, 15, 22, 0.98)),
    var(--color-surface-1, #111923);
}

.topbar-title {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.15rem;
  letter-spacing: 0.02em;
  color: var(--parchment);
  text-decoration: none;
  text-transform: uppercase;
}

.brand-mark::after {
  content: "// DW-01";
  margin-left: 0.2rem;
  color: var(--ash);
  font: 500 0.58rem/1 var(--mono);
  letter-spacing: 0.08em;
}

.brand-mark:hover {
  color: var(--parchment);
}

.brand-ember {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 0;
  background: var(--torch);
  box-shadow: 2px 0 #9a3f14, 0 2px #9a3f14, -2px 0 #ffd7a8, 0 -2px #ffd7a8, 0 0 12px var(--ember-glow);
  transform: rotate(45deg);
  flex-shrink: 0;
}

.topbar-subtitle {
  font-size: 0.78rem;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.topbar-nav {
  display: flex;
  gap: 0.35rem;
  align-items: center;
}

.topbar-nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  padding: 0.35rem 0.7rem;
  border-radius: 0;
  border: 1px solid transparent;
  transition: color 0.15s var(--ease), background 0.15s var(--ease), border-color 0.15s var(--ease);
}

.topbar-nav a:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.topbar-nav a.active {
  color: var(--torch);
  border-color: rgba(224, 122, 61, 0.35);
  background: var(--ember-soft);
}

.topbar-nav a.active::before {
  content: "> ";
}

.topbar-controls {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--ledge);
  background: rgba(0, 0, 0, 0.22);
  font-size: 0.75rem;
  color: var(--muted);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-pill.is-error {
  border-color: rgba(210, 102, 102, 0.45);
  color: #f0b0b0;
}

.status-dot {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--moss);
  box-shadow: 0 0 0 0 rgba(111, 168, 122, 0.5);
  animation: pulse-live 2.2s var(--ease) infinite;
  flex-shrink: 0;
}

.status-dot.paused,
.status-dot.idle {
  background: var(--ash);
  animation: none;
  box-shadow: none;
}

.status-dot.error {
  background: var(--blood);
  animation: none;
}

@keyframes pulse-live {
  0% { box-shadow: 0 0 0 0 rgba(111, 168, 122, 0.45); }
  70% { box-shadow: 0 0 0 8px rgba(111, 168, 122, 0); }
  100% { box-shadow: 0 0 0 0 rgba(111, 168, 122, 0); }
}

.toggle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.86rem;
  cursor: pointer;
  color: var(--muted);
  user-select: none;
}

.toggle input {
  accent-color: var(--ember);
}

/* ── Buttons ────────────────────────────────────────────── */

button {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border: 1px solid var(--ledge);
  border-radius: 0;
  padding: 0.4rem 0.8rem;
  cursor: pointer;
  font: inherit;
  font-weight: 500;
  box-shadow: inset 1px 1px rgba(255, 255, 255, 0.07), 2px 2px 0 var(--pixel-shadow);
  transition: border-color 80ms linear, background 80ms linear, color 80ms linear, transform 80ms steps(2, end);
}

button:hover {
  border-color: var(--color-border-strong, #3c5264);
  color: var(--parchment);
  background: rgba(255, 255, 255, 0.06);
}

button.btn-accent:hover,
button.primary:hover,
.composer-send:hover,
.composer-modes > button.is-active:hover {
  border-color: var(--torch);
  color: var(--torch);
  background: var(--ember-soft);
}

button:active {
  transform: translate(2px, 2px);
  box-shadow: inset 1px 1px rgba(0, 0, 0, 0.22);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  filter: grayscale(0.15);
}

.play-card .btn-sm:not(:disabled),
.play-card button:not(.btn-accent):not(:disabled) {
  border-color: rgba(255, 255, 255, 0.16);
  color: var(--parchment);
  background: rgba(255, 255, 255, 0.05);
}

.play-card .btn-sm:disabled,
.play-card button:disabled {
  border-style: dashed;
  opacity: 0.5;
}

.btn-sm {
  font-size: 0.74rem;
  padding: 0.22rem 0.55rem;
  border-radius: var(--radius-sm);
  line-height: 1.35;
  font-weight: 600;
}

.btn-danger {
  border-color: rgba(210, 102, 102, 0.55);
  color: #f0a0a0;
}
.btn-danger:hover {
  background: var(--blood-soft);
  border-color: var(--blood);
  color: #ffc4c4;
}

.btn-ok {
  border-color: rgba(111, 168, 122, 0.55);
  color: #9fd0a8;
}
.btn-ok:hover {
  background: var(--moss-soft);
  border-color: var(--moss);
  color: #c5e8cb;
}

.btn-accent {
  border-color: rgba(224, 122, 61, 0.55);
  color: #ffd2a8;
  background: linear-gradient(180deg, rgba(224, 122, 61, 0.24), rgba(224, 122, 61, 0.12));
}
.btn-accent:hover {
  background: linear-gradient(180deg, rgba(224, 122, 61, 0.34), rgba(224, 122, 61, 0.18));
  border-color: var(--ember);
  color: #ffe0c0;
}
.btn-accent:disabled {
  opacity: 0.55;
  color: rgba(255, 210, 168, 0.72);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}
.btn-ghost:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  border-color: transparent;
}

/* ── Layout ─────────────────────────────────────────────── */

.grid-main {
  display: grid;
  grid-template-columns: 240px minmax(280px, 1.15fr) minmax(250px, 1fr) minmax(300px, 1.15fr);
  gap: 0.85rem;
  padding: 0.85rem;
  min-height: calc(100vh - var(--topbar-h));
  align-items: start;
}

.steering-banner {
  grid-column: 1 / -1;
  padding: 0.65rem 0.85rem;
  border: 1px solid rgba(224, 122, 61, 0.42);
  border-radius: var(--radius);
  background: var(--ember-soft);
  color: var(--text);
  font-size: 0.9rem;
}

.back-to-play {
  grid-column: 1 / -1;
  justify-self: start;
  color: var(--torch);
  font-size: 0.85rem;
}

@media (max-width: 1280px) {
  .grid-main {
    grid-template-columns: 220px 1fr 1fr;
  }
  .panel-narrative {
    grid-column: 1 / -1;
  }
}

@media (max-width: 900px) {
  .grid-main {
    grid-template-columns: 1fr 1fr;
  }
  .panel-games {
    grid-column: 1 / -1;
  }
}

@media (max-width: 680px) {
  .grid-main {
    grid-template-columns: 1fr;
    padding: 0.65rem;
  }
  .topbar-controls {
    width: 100%;
    margin-left: 0;
  }
}

.panel {
  background: linear-gradient(165deg, rgba(28, 38, 50, 0.96), rgba(20, 28, 38, 0.98));
  border: 2px solid var(--ledge);
  border-radius: 0;
  padding: 0.9rem;
  min-height: 120px;
  max-height: calc(100vh - var(--topbar-h) - 1.7rem);
  overflow: auto;
  box-shadow: inset 1px 1px var(--pixel-highlight), inset -1px -1px var(--pixel-shadow), 6px 6px 0 rgba(0, 0, 0, 0.34);
  animation: panel-in 0.35s var(--ease) both;
}

.panel-games { animation-delay: 0.02s; }
.panel-party { animation-delay: 0.06s; }
.panel-world { animation-delay: 0.1s; }
.panel-narrative { animation-delay: 0.14s; }

@keyframes panel-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.panel h2,
.section-label {
  margin: 0 0 0.65rem;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--ash);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}

.panel-header h2 {
  margin: 0;
}

.section-split {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin: 1.15rem 0 0.55rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--ledge-soft);
}

.section-split h2 {
  margin: 0;
}

/* ── Empty / loading ────────────────────────────────────── */

.empty-state {
  position: relative;
  padding: 1.35rem 1rem;
  border: 1px solid var(--ledge-soft);
  border-radius: var(--radius-xs, 2px);
  background:
    radial-gradient(ellipse at 30% 20%, rgba(232, 139, 67, 0.06), transparent 55%),
    radial-gradient(ellipse at 80% 90%, rgba(111, 159, 191, 0.05), transparent 50%),
    linear-gradient(180deg, rgba(17, 25, 35, 0.9), rgba(9, 14, 20, 0.75));
  box-shadow: var(--surface-frame, inset 1px 1px 0 rgba(255, 255, 255, 0.04));
  text-align: left;
  overflow: hidden;
}

.empty-state::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.04;
  background-image:
    linear-gradient(rgba(233, 226, 213, 0.8) 1px, transparent 1px),
    linear-gradient(90deg, rgba(233, 226, 213, 0.8) 1px, transparent 1px);
  background-size: 10px 10px;
}

.empty-state p {
  position: relative;
  margin: 0 0 0.35rem;
  color: var(--text);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.03em;
}

.empty-state .hint {
  position: relative;
  margin: 0;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 0.84rem;
  font-weight: 400;
  line-height: 1.5;
}

.empty-state .empty-actions {
  margin-top: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.loading-line {
  height: 0.7rem;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--ledge) 0%, rgba(255,255,255,0.08) 50%, var(--ledge) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
  margin-bottom: 0.45rem;
}

@keyframes shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

/* ── Games list ─────────────────────────────────────────── */

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

.games-list li {
  margin-bottom: 0.4rem;
}

.games-list button {
  width: 100%;
  text-align: left;
  padding: 0.65rem 0.7rem;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid transparent;
  position: relative;
  overflow: hidden;
}

.games-list button::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: transparent;
  transition: background 0.15s var(--ease);
}

.games-list button:hover {
  border-color: var(--ledge);
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
}

.games-list button.active {
  border-color: rgba(224, 122, 61, 0.4);
  background: var(--ember-soft);
}

.games-list button.active::before {
  background: linear-gradient(180deg, var(--torch), var(--ember));
  box-shadow: 0 0 10px var(--ember-glow);
}

.game-name {
  font-weight: 650;
  display: block;
  font-size: 0.92rem;
  letter-spacing: -0.01em;
}

.game-meta {
  font-size: 0.72rem;
  color: var(--muted);
  font-family: var(--mono);
  margin-top: 0.15rem;
  display: block;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.68rem;
  font-weight: 650;
  padding: 0.12rem 0.4rem;
  border-radius: 999px;
  margin-top: 0.35rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.badge-live {
  background: var(--moss-soft);
  color: #9fd0a8;
}

.badge-idle {
  background: rgba(139, 149, 165, 0.14);
  color: var(--muted);
}

.badge-warn {
  background: rgba(240, 168, 106, 0.16);
  color: var(--torch);
}

/* ── Game header ────────────────────────────────────────── */

.game-header {
  margin-bottom: 1rem;
  padding: 0.85rem;
  border: 1px solid var(--ledge-soft);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(224, 122, 61, 0.08), transparent 55%),
    rgba(0, 0, 0, 0.2);
}

.game-header h1 {
  margin: 0 0 0.3rem;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.game-header-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
  align-items: center;
  margin-top: 0.45rem;
}

/* ── Party cards ────────────────────────────────────────── */

.party-cards {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.card {
  border: 1px solid var(--ledge-soft);
  border-radius: var(--radius);
  padding: 0.8rem;
  background: rgba(0, 0, 0, 0.22);
  transition: border-color 0.15s var(--ease);
}

.card:hover {
  border-color: rgba(224, 122, 61, 0.28);
}

.card.level-up-ready {
  border-color: rgba(111, 168, 122, 0.45);
  box-shadow: inset 0 0 0 1px rgba(111, 168, 122, 0.12);
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.card h3 {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.card-class {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 500;
}

.vital-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  font-size: 0.78rem;
  font-family: var(--mono);
  margin-bottom: 0.2rem;
}

.card dl {
  margin: 0.45rem 0 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.18rem 0.7rem;
  font-size: 0.84rem;
}

.card dt {
  color: var(--muted);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.28rem;
  margin-top: 0.35rem;
}

.chip {
  font-size: 0.72rem;
  padding: 0.14rem 0.45rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--ledge-soft);
  color: var(--text);
}

.chip-debility {
  background: var(--blood-soft);
  border-color: rgba(210, 102, 102, 0.35);
  color: #f0a8a8;
}

.chip-prepared {
  background: rgba(240, 168, 106, 0.14);
  border-color: rgba(240, 168, 106, 0.35);
  color: #ffd0a8;
  font-weight: 600;
}

.hp-bar,
.xp-bar {
  height: 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  margin: 0.25rem 0 0.35rem;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.xp-bar {
  height: 4px;
  margin: 0.15rem 0 0.25rem;
}

.hp-bar > span,
.xp-bar > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  transition: width 0.35s var(--ease);
}

.hp-bar > span {
  background: linear-gradient(90deg, #4e8f5c, var(--moss));
  box-shadow: 0 0 8px rgba(111, 168, 122, 0.35);
}

.hp-bar.low > span {
  background: linear-gradient(90deg, var(--ember), var(--blood));
  box-shadow: 0 0 8px rgba(210, 102, 102, 0.35);
}

.xp-bar > span {
  background: linear-gradient(90deg, #c96a35, var(--torch));
}

.ability-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.28rem;
  margin: 0.55rem 0 0.2rem;
}

.ability-chip {
  text-align: center;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--ledge-soft);
  border-radius: var(--radius-sm);
  padding: 0.25rem 0.1rem;
  line-height: 1.25;
}

.ability-chip .ab-name {
  display: block;
  font-size: 0.58rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 650;
}

.ability-chip .ab-score {
  display: block;
  font-weight: 700;
  font-size: 0.84rem;
  font-family: var(--mono);
}

.ability-chip .ab-mod {
  display: block;
  font-size: 0.68rem;
  font-family: var(--mono);
  color: var(--torch);
}

.card-details {
  margin-top: 0.45rem;
  border-top: 1px solid var(--ledge-soft);
  padding-top: 0.2rem;
}

.card-details summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.35rem 0;
  list-style: none;
  user-select: none;
}

.card-details summary::-webkit-details-marker {
  display: none;
}

.card-details summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 0.35rem;
  color: var(--ember);
  transition: transform 0.15s var(--ease);
}

.card-details[open] summary::before {
  transform: rotate(90deg);
}

.card-details summary:hover {
  color: var(--text);
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.65rem;
}

/* ── World / encounters / fronts ────────────────────────── */

.stack > article {
  border: 1px solid var(--ledge-soft);
  border-radius: var(--radius);
  padding: 0.65rem 0.75rem;
  margin-bottom: 0.55rem;
  font-size: 0.88rem;
  background: rgba(0, 0, 0, 0.18);
}

.stack h4 {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
  font-weight: 650;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}

.create-block {
  margin: 0 0 0.75rem;
  padding: 0.55rem 0.65rem;
  border: 1px dashed rgba(255, 255, 255, 0.14);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.02);
}

.create-block summary {
  cursor: pointer;
  font-weight: 600;
}

.inline-form {
  display: grid;
  gap: 0.45rem;
  margin-top: 0.55rem;
}

.monster-row {
  margin: 0.5rem 0;
  padding: 0.45rem 0.5rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid transparent;
}

.monster-row:hover {
  border-color: var(--ledge-soft);
}

.monster-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
  justify-content: space-between;
}

.state-summary .beats {
  max-height: 200px;
  overflow: auto;
  font-size: 0.85rem;
}

.beat {
  border-left: 3px solid var(--ember);
  padding: 0.4rem 0.55rem;
  margin-bottom: 0.4rem;
  background: rgba(0, 0, 0, 0.18);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.event-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-bottom: 0.55rem;
}

.event-filters button.filter-chip {
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  opacity: 0.55;
  border-radius: 999px;
}

.event-filters button.filter-chip.on {
  opacity: 1;
  border-color: rgba(224, 122, 61, 0.5);
  color: var(--torch);
  background: var(--ember-soft);
}

.event-log {
  height: min(48vh, 400px);
  overflow: auto;
  background: rgba(8, 11, 16, 0.85);
  border: 1px solid var(--ledge-soft);
  border-radius: var(--radius);
  padding: 0.35rem;
  font-size: 0.74rem;
}

.event-row {
  border-bottom: 1px solid rgba(44, 56, 72, 0.55);
  padding: 0.4rem 0.3rem;
  cursor: pointer;
}

.event-row:hover {
  background: var(--ember-soft);
}

.event-row summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 0.55rem;
  align-items: baseline;
  list-style: none;
}

.event-row summary::-webkit-details-marker {
  display: none;
}

.event-seq {
  color: var(--muted);
}

.event-type {
  color: var(--torch);
  font-weight: 650;
}

.event-time {
  color: var(--muted);
  font-size: 0.68rem;
}

.event-payload-preview {
  color: var(--muted);
  flex: 1;
  min-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.event-json {
  margin: 0.35rem 0 0;
  padding: 0.55rem;
  background: #05070a;
  border-radius: var(--radius-sm);
  overflow: auto;
  max-height: 200px;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid var(--ledge-soft);
}

.error-banner {
  background: var(--blood-soft);
  border: 1px solid rgba(210, 102, 102, 0.45);
  color: #f0b0b0;
  padding: 0.55rem 0.7rem;
  border-radius: var(--radius);
  margin-bottom: 0.55rem;
  font-size: 0.85rem;
}

details.danger-block {
  margin-top: 0.4rem;
  font-size: 0.84rem;
  padding: 0.35rem 0.45rem;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.12);
}

details.danger-block summary {
  cursor: pointer;
  color: var(--muted);
}

details.danger-block summary strong {
  color: var(--text);
}

.portents {
  margin: 0.3rem 0 0;
  padding-left: 1.1rem;
}

.portents li {
  margin: 0.25rem 0;
}

.portents li.done {
  text-decoration: line-through;
  color: var(--muted);
}

/* ── Dialogs ────────────────────────────────────────────── */

dialog {
  background: linear-gradient(165deg, #1e2a38, var(--stone));
  color: var(--text);
  border: 1px solid rgba(224, 122, 61, 0.25);
  border-radius: calc(var(--radius) + 2px);
  padding: 1.35rem;
  max-width: 480px;
  width: 92vw;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}

dialog::backdrop {
  background: rgba(6, 9, 14, 0.72);
  backdrop-filter: blur(3px);
}

.dialog-title {
  margin: 0 0 0.35rem;
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.dialog-lead {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.86rem;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1.25rem;
}

.dialog-error {
  background: var(--blood-soft);
  border: 1px solid rgba(210, 102, 102, 0.45);
  color: #f0b0b0;
  padding: 0.45rem 0.65rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  margin-top: 0.65rem;
}

.dialog-result {
  margin-top: 0.75rem;
  padding: 0.6rem 0.75rem;
  background: var(--moss-soft);
  border: 1px solid rgba(111, 168, 122, 0.4);
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
}

.form-group {
  margin-bottom: 0.8rem;
}

.form-label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.3rem;
  font-weight: 600;
}

.form-input,
.form-select {
  width: 100%;
  padding: 0.45rem 0.6rem;
  background: rgba(0, 0, 0, 0.28);
  color: var(--text);
  border: 1px solid var(--ledge);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 0.9rem;
}

.form-input:focus,
.form-select:focus {
  outline: none;
  border-color: var(--ember);
  box-shadow: 0 0 0 3px var(--ember-soft);
}

.form-check {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
  font-size: 0.86rem;
}

.form-check input[type="checkbox"] {
  margin-top: 0.18rem;
  flex-shrink: 0;
  accent-color: var(--ember);
}

.dialog-section {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin: 0.9rem 0 0.45rem;
}

.eos-char-block {
  border: 1px solid var(--ledge-soft);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.7rem;
  margin-bottom: 0.5rem;
  font-size: 0.86rem;
  background: rgba(0, 0, 0, 0.15);
}

/* ── Toasts ─────────────────────────────────────────────── */

.toast-container {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  background: var(--stone);
  border: 1px solid var(--ledge);
  border-radius: var(--radius);
  padding: 0.65rem 0.95rem;
  font-size: 0.86rem;
  max-width: 320px;
  box-shadow: var(--shadow);
  animation: toast-in 0.22s var(--ease);
  pointer-events: auto;
}

.toast-success { border-left: 3px solid var(--moss); }
.toast-error   { border-left: 3px solid var(--blood); color: #f0b0b0; }
.toast-info    { border-left: 3px solid var(--ember); }

.toast-out {
  animation: toast-out 0.25s var(--ease) forwards;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes toast-out {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(8px); }
}

/* ── Content catalog page ───────────────────────────────── */

.content-shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1rem 1.1rem 2rem;
}

.content-hero {
  margin-bottom: 1rem;
}

.content-hero h1 {
  margin: 0 0 0.25rem;
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 2.5vw, 2rem);
  font-weight: 650;
  letter-spacing: -0.02em;
}

.content-hero p {
  margin: 0;
  color: var(--muted);
  max-width: 42rem;
}

.content-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: end;
  margin-bottom: 0.9rem;
  padding: 0.85rem;
  border: 1px solid var(--ledge-soft);
  border-radius: var(--radius);
  background: rgba(24, 34, 46, 0.85);
  box-shadow: var(--shadow);
}

.content-toolbar .field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 160px;
  flex: 1;
}

.content-toolbar label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.content-toolbar select,
.content-toolbar input {
  padding: 0.45rem 0.6rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--ledge);
  background: rgba(0, 0, 0, 0.28);
  color: var(--text);
  font: inherit;
}

.content-layout {
  display: grid;
  grid-template-columns: minmax(220px, 300px) 1fr;
  gap: 0.85rem;
  min-height: 60vh;
}

@media (max-width: 800px) {
  .content-layout {
    grid-template-columns: 1fr;
  }
}

.content-list,
.content-detail {
  border: 1px solid var(--ledge-soft);
  border-radius: var(--radius);
  background: rgba(24, 34, 46, 0.9);
  box-shadow: var(--shadow);
  overflow: hidden;
  min-height: 320px;
}

.content-list-header,
.content-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 0.85rem;
  border-bottom: 1px solid var(--ledge-soft);
  background: rgba(0, 0, 0, 0.18);
}

.content-list-header h2,
.content-detail-header h2 {
  margin: 0;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.content-count {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--ash);
}

.content-items {
  list-style: none;
  margin: 0;
  padding: 0.35rem;
  max-height: calc(100vh - 260px);
  overflow: auto;
}

.content-items li button {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.65rem;
  margin-bottom: 0.2rem;
}

.content-items li button:hover {
  background: rgba(255, 255, 255, 0.03);
  border-color: var(--ledge);
  color: var(--text);
}

.content-items li button.active {
  background: var(--ember-soft);
  border-color: rgba(224, 122, 61, 0.4);
  color: var(--text);
}

.content-item-id {
  display: block;
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 500;
}

.content-item-name {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.1rem;
}

.content-pre {
  margin: 0;
  padding: 0.9rem;
  max-height: calc(100vh - 260px);
  overflow: auto;
  font-size: 0.8rem;
  line-height: 1.45;
  background: rgba(8, 11, 16, 0.55);
}

/* ── Reduced motion ─────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .status-dot {
    box-shadow: none;
  }
}

/* ── Pixel field-desk skin ─────────────────────────────── */
.play-gate.panel {
  position: relative;
  background:
    linear-gradient(90deg, rgba(240, 168, 106, 0.035) 1px, transparent 1px),
    linear-gradient(rgba(240, 168, 106, 0.025) 1px, transparent 1px),
    var(--pixel-panel);
  background-size: 16px 16px;
}

.play-gate.panel::before,
.play-gate.panel::after {
  content: "";
  position: absolute;
  width: 8px;
  height: 8px;
  border: solid var(--torch);
  pointer-events: none;
}

.play-gate.panel::before { top: 6px; left: 6px; border-width: 2px 0 0 2px; }
.play-gate.panel::after { right: 6px; bottom: 6px; border-width: 0 2px 2px 0; }

.play-hero {
  text-shadow: 3px 3px 0 #080c11;
}

.play-hero::before {
  content: "◆";
  margin-right: 0.55rem;
  color: var(--torch);
  font: 0.55em/1 var(--mono);
  vertical-align: 0.18em;
}

.play-card {
  border: 2px solid var(--ledge);
  border-radius: 0;
  background: #0f161f;
  box-shadow: inset 1px 1px var(--pixel-highlight), inset -1px -1px #070b0f, 4px 4px 0 rgba(0, 0, 0, 0.3);
}

.play-card h2 {
  color: var(--torch);
  font: 600 0.92rem/1.35 var(--mono);
  letter-spacing: 0.035em;
  text-transform: uppercase;
}

.play-card h2::before {
  content: "[";
  color: var(--ash);
}

.play-card h2::after {
  content: "]";
  color: var(--ash);
}

.field input,
.field select,
.field textarea,
.chat-compose textarea {
  border: 2px solid #293545;
  border-radius: 0;
  box-shadow: inset 2px 2px 0 #05080c, inset -1px -1px var(--pixel-highlight);
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.chat-compose textarea:focus {
  border-color: var(--torch);
  box-shadow: inset 2px 2px 0 #05080c, 0 0 0 2px rgba(240, 168, 106, 0.18);
}

.play-step-num {
  border-radius: 0;
  box-shadow: 2px 2px 0 var(--pixel-shadow);
}

.play-steps {
  border-top-width: 2px;
  border-top-style: dashed;
}

.chat-log {
  border: 2px solid var(--ledge);
  border-radius: 0;
  background:
    repeating-linear-gradient(0deg, transparent 0 23px, rgba(255, 255, 255, 0.018) 23px 24px),
    #0a1017;
  box-shadow: inset 3px 3px 0 #05080c;
}

.chat-msg {
  border-radius: 0;
  border-left: 3px solid var(--ledge);
  background: rgba(255, 255, 255, 0.018);
}

.chat-narrator { border-left-color: var(--torch); }
.chat-system { border-left-style: dashed; }

.phase-pill,
.status-pill {
  border-width: 2px;
  box-shadow: inset 1px 1px rgba(255, 255, 255, 0.06), 2px 2px 0 var(--pixel-shadow);
}

@media (max-width: 560px) {
  .brand-mark::after { display: none; }
  .play-body:not(.is-in-room) .play-shell { padding: 0.65rem 0.65rem 5rem; }
  .play-body.is-in-room .play-shell { padding: 0; }
  .play-gate.panel { padding: 1rem; }
  .play-hero { font-size: 1.8rem; }
}

/* ── Play (multiplayer) ─────────────────────────────────── */

.hidden {
  display: none !important;
}

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

.play-shell {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.25rem 1.25rem 3rem;
  min-height: calc(100dvh - var(--topbar-h));
  box-sizing: border-box;
}

/* Gate fills the viewport; content stays readable in the center */
.play-body:not(.is-in-room) .play-shell {
  max-width: none;
  width: 100%;
  margin: 0;
  padding: 1.25rem clamp(1rem, 3vw, 2.5rem) 2rem;
  display: flex;
  flex-direction: column;
}

.play-body:not(.is-in-room) .play-gate.panel {
  flex: 1 1 auto;
  width: min(72rem, 100%);
  max-width: 72rem;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: calc(100dvh - var(--topbar-h) - 2.5rem);
}

.play-body:not(.is-in-room) .play-gate-grid {
  grid-template-columns: minmax(0, 32rem);
}

/* In-room: edge-to-edge stage under the topbar */
.play-body.is-in-room {
  overflow: hidden;
}

.play-body.is-in-room .play-shell {
  max-width: none;
  width: 100%;
  margin: 0;
  padding: 0;
  height: calc(100dvh - var(--topbar-h));
  min-height: calc(100dvh - var(--topbar-h));
  display: flex;
  flex-direction: column;
}

.play-body.is-in-room .play-room {
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  gap: 0;
  grid-template-columns: minmax(18rem, 24rem) minmax(0, 1fr);
  align-items: stretch;
}

.play-body.is-in-room .play-room.is-playing {
  grid-template-columns: 1fr;
  grid-template-rows: minmax(0, 1fr);
}

.play-body.is-in-room .play-workspace.panel,
.play-body.is-in-room .play-chat.panel {
  max-height: none;
  height: 100%;
  border-radius: 0;
  box-shadow: none;
}

.play-body.is-in-room .play-workspace.panel {
  border-right: 1px solid var(--color-border-strong, var(--ledge));
  border-left: 0;
  border-top: 0;
  border-bottom: 0;
}

.play-body.is-in-room .play-room.is-playing .play-workspace.panel,
.play-body.is-in-room .play-room.is-playing .play-chat.panel {
  border: 0;
}

.play-body.is-in-room .play-chat.panel {
  border: 0;
}

.play-gate.panel {
  max-height: none;
  padding: 1.35rem 1.4rem 1.5rem;
  background:
    linear-gradient(180deg, rgba(36, 46, 60, 0.55), transparent 42%),
    linear-gradient(165deg, rgba(28, 38, 50, 0.96), rgba(20, 28, 38, 0.98));
}

.play-hero {
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 3.5vw, 2.4rem);
  font-weight: 600;
  margin: 0 0 0.55rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--parchment);
  line-height: 1.15;
}

.lede {
  color: var(--muted);
  max-width: 40rem;
  margin: 0 0 1.65rem;
  font-size: 1.02rem;
  line-height: 1.55;
}

.play-gate-grid {
  display: grid;
  grid-template-columns: minmax(0, 28rem);
  justify-content: center;
  gap: 0.85rem;
  margin-bottom: 1.35rem;
  align-items: stretch;
}

.play-gate-progressive .play-gate-step.is-gate-deferred {
  display: none;
}

.play-gate-progressive .play-gate-step.is-gate-active,
.play-gate-progressive[data-gate-step="identity"] [data-gate-panel="identity"],
.play-gate-progressive[data-gate-step="choice"] [data-gate-panel="choice"],
.play-gate-progressive[data-gate-step="host"] [data-gate-panel="host"],
.play-gate-progressive[data-gate-step="join"] [data-gate-panel="join"] {
  display: flex;
}

.gate-choice-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

@media (max-width: 900px) {
  .play-gate-grid {
    grid-template-columns: 1fr;
  }
}

.play-card {
  display: flex;
  flex-direction: column;
  background: rgba(8, 11, 16, 0.42);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--radius);
  padding: 1rem 1.05rem 1.1rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.play-card h2 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 650;
  margin: 0 0 0.85rem;
  color: var(--parchment);
  text-transform: none;
  letter-spacing: -0.015em;
}

.play-card .btn-accent,
.play-card .btn-sm {
  margin-top: auto;
}

.play-steps {
  list-style: none;
  margin: 0.35rem 0 0;
  padding: 0.95rem 0 0;
  border-top: 1px solid var(--ledge-soft);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.65rem;
}

.play-steps li {
  display: flex;
  gap: 0.55rem;
  align-items: flex-start;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.4;
  margin: 0;
}

.play-step-num {
  flex-shrink: 0;
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--torch);
  background: var(--ember-soft);
  border: 1px solid rgba(224, 122, 61, 0.3);
  margin-top: 0.05rem;
}

.play-steps strong {
  color: var(--parchment);
  font-weight: 600;
}

@media (max-width: 900px) {
  .play-steps {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 560px) {
  .play-steps {
    grid-template-columns: 1fr;
  }
}

.play-room {
  display: grid;
  grid-template-columns: minmax(340px, 0.95fr) minmax(380px, 1.2fr);
  gap: 1rem;
  min-height: calc(100vh - var(--topbar-h) - 2.5rem);
  align-items: stretch;
}

@media (max-width: 900px) {
  .play-room {
    grid-template-columns: 1fr;
  }

  .play-chat {
    order: -1;
  }

  .play-workspace {
    order: 1;
  }

  .play-chat .chat-log {
    min-height: 42vh;
  }
}

.play-workspace,
.play-chat {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.play-workspace.panel,
.play-chat.panel {
  max-height: calc(100vh - var(--topbar-h) - 2.5rem);
}

.play-workspace .panel-header h2,
.play-chat .panel-header h2 {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--parchment);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.play-workspace {
  overflow: auto;
  gap: 0.55rem;
  scrollbar-gutter: stable;
}

.phase-workspace {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  /* Do NOT use flex:1 here — multiple workspaces can be visible at once
     (lobby + char create, ready + bonds). flex:1 + min-height:0 compresses
     them into the same band and overflowing text stacks on top of itself. */
}

.phase-workspace.hidden {
  display: none !important;
}

/* Only the playing desk fills leftover sidebar height */
#workspacePlaying:not(.hidden) {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

.workspace-header {
  margin-bottom: 0.35rem;
}

.workspace-header h3 {
  margin: 0 0 0.3rem;
}

.workspace-header p {
  margin: 0;
  line-height: 1.45;
}

.host-strip {
  margin: 0.1rem 0 0.35rem;
  padding: 0.65rem 0.75rem 0.7rem;
  border: 1px solid var(--ledge);
  border-radius: var(--radius-xs, 2px);
  background:
    linear-gradient(135deg, rgba(232, 139, 67, 0.05), transparent 55%),
    var(--color-surface-1, rgba(8, 11, 16, 0.55));
  box-shadow: var(--surface-frame, inset 1px 1px 0 rgba(255, 255, 255, 0.04));
}

.host-strip-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--torch);
  margin-bottom: 0.45rem;
}

.host-strip-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
}

.host-strip-tools {
  margin: 0;
  padding-top: 0.45rem;
  border-top: 1px solid rgba(224, 122, 61, 0.12);
}

.host-strip-tools .btn-sm {
  opacity: 0.92;
}

.host-strip-phases .phase-btn {
  border-radius: 999px;
  padding-inline: 0.7rem;
}

.host-strip-phases .phase-btn.is-active {
  background: var(--ember-soft);
  border-color: rgba(224, 122, 61, 0.55);
  color: var(--torch);
  box-shadow: 0 0 0 1px rgba(224, 122, 61, 0.15);
}

.host-strip .open-table-link {
  margin-top: 0;
  border-color: rgba(224, 122, 61, 0.45);
  color: var(--torch);
  background: var(--ember-soft);
}

.host-strip .open-table-link:hover {
  border-color: var(--ember);
  color: #ffd7b0;
}

.lobby-host-start {
  margin-top: 0.35rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--ledge-soft);
}

.lobby-host-start .btn-accent {
  width: 100%;
  padding: 0.65rem 1rem;
  font-size: 0.95rem;
}

.bond-forge,
.play-desk {
  margin-top: 0.1rem;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  min-height: 0;
}

.play-desk {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.desk-panel {
  padding: 0.85rem 0.9rem;
  border: 1px solid var(--ledge);
  border-radius: var(--radius-xs, 2px);
  background:
    linear-gradient(180deg, rgba(29, 41, 53, 0.35), transparent 40%),
    var(--color-surface-1, rgba(8, 11, 16, 0.55));
  box-shadow: var(--surface-frame, inset 1px 1px 0 rgba(255, 255, 255, 0.04));
}

.desk-panel h3 {
  font-family: var(--font-display);
  font-size: 0.92rem;
  font-weight: 600;
  margin: 0 0 0.55rem;
  color: var(--parchment);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.desk-sheet-body {
  line-height: 1.45;
  display: grid;
  gap: 0.65rem;
  color: var(--text);
  font-size: 0.9rem;
}

.desk-sheet-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.35rem 0.75rem;
}

.desk-pc-name {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--parchment);
  letter-spacing: 0.02em;
}

.desk-hp {
  display: grid;
  gap: 0.35rem;
}

.desk-hp-bar {
  height: 0.55rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.desk-hp-bar > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #b84a22, var(--ember) 55%, #f0a86a);
  border-radius: inherit;
  box-shadow: 0 0 10px rgba(224, 122, 61, 0.25);
}

.desk-abilities {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.35rem;
}

.desk-ability {
  font-size: 0.82rem;
  padding: 0.35rem 0.45rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  text-align: center;
}

.desk-ability-id {
  display: block;
  color: var(--muted);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 0.1rem;
}

.desk-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.desk-badge {
  font-size: 0.75rem;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  border: 1px solid rgba(224, 122, 61, 0.35);
  background: var(--ember-soft);
  color: var(--torch);
}

.desk-section {
  display: grid;
  gap: 0.25rem;
}

.desk-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
}

.desk-list {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.88rem;
}

.desk-debilities {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.desk-debility {
  font-size: 0.78rem;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: var(--blood-soft);
  border: 1px solid rgba(210, 102, 102, 0.35);
  color: #f0b4a8;
}

.desk-encounter {
  display: grid;
  gap: 0.45rem;
  margin-bottom: 0.65rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--ledge-soft);
}

.desk-encounter:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.desk-encounter-name {
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--parchment);
}

.threat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.threat-chip {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.3rem 0.45rem;
  padding: 0.4rem 0.55rem;
  border: 1px solid rgba(210, 102, 102, 0.28);
  border-radius: var(--radius-sm);
  background: rgba(210, 102, 102, 0.08);
  font-size: 0.85rem;
}

.threat-chip.defeated {
  opacity: 0.45;
  text-decoration: line-through;
  border-color: rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.22);
}

.desk-moves-hint {
  margin: 0 0 0.55rem;
}

.desk-move-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.desk-move-chip {
  font-size: 0.8rem;
  line-height: 1.3;
  white-space: normal;
  text-align: left;
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  background: rgba(255, 255, 255, 0.04);
}

.desk-move-chip:hover {
  background: var(--ember-soft);
}

.desk-move-class,
.desk-move-learned {
  border-color: rgba(120, 170, 220, 0.4);
  color: #b8d4f0;
}

.bond-forge {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding: 0.95rem 1rem 1.05rem;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--radius);
  background: rgba(8, 11, 16, 0.38);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.bond-forge h3,
.play-desk > .desk-panel h3 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 650;
  margin: 0 0 0.35rem;
  color: var(--parchment);
  letter-spacing: -0.015em;
}

.bond-forge h4 {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 650;
  margin: 0.15rem 0 0.4rem;
  color: var(--parchment);
  text-transform: none;
  letter-spacing: -0.01em;
}

.bond-forge-list,
.bond-forge-party-list {
  list-style: none;
  margin: 0 0 0.55rem;
  padding: 0;
}

.bond-forge-list li,
.bond-forge-party-list li {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.55rem;
  padding: 0.5rem 0.15rem;
  border-bottom: 1px solid var(--ledge-soft);
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.4;
}

.bond-forge-list li:last-child,
.bond-forge-party-list li:last-child {
  border-bottom: none;
}

.bond-forge-form {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-top: 0.35rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--ledge-soft);
}

.bond-templates {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.bond-templates .bond-tpl {
  font-size: 0.78rem;
  line-height: 1.3;
  padding: 0.35rem 0.6rem;
  max-width: 100%;
  text-align: left;
  white-space: normal;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
}

.bond-templates .bond-tpl:hover {
  background: var(--ember-soft);
}

.bond-forge-party {
  margin-top: 0.15rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--ledge-soft);
}

.bond-forge-party-pc {
  margin-bottom: 0.7rem;
  padding: 0.55rem 0.65rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.bond-forge-party-pc strong {
  display: block;
  margin-bottom: 0.25rem;
  color: var(--parchment);
}

.bond-forge-party-pc ul {
  list-style: disc;
  margin: 0 0 0 1.1rem;
  padding: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.bond-forge-party-pc.bond-missing {
  border-color: rgba(224, 122, 61, 0.35);
  background: rgba(224, 122, 61, 0.06);
}

.bond-forge-party-pc.bond-missing strong {
  color: var(--torch);
}

.invite-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  margin: 0.15rem 0;
}

.member-list {
  list-style: none;
  margin: 0 0 0.5rem;
  padding: 0;
}

.member-list li {
  padding: 0.55rem 0.15rem;
  border-bottom: 1px solid var(--ledge-soft);
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 0.55rem;
}

.char-create {
  margin-top: 0;
  padding: 0.95rem 1rem 1.05rem;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--radius);
  background: rgba(8, 11, 16, 0.38);
}

.char-create h3 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 650;
  margin: 0 0 0.35rem;
  color: var(--parchment);
  text-transform: none;
  letter-spacing: -0.015em;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 0.7rem;
  font-size: 0.85rem;
}

.field span {
  color: var(--muted);
  font-weight: 500;
}

.field input,
.field select,
.field textarea,
.chat-compose textarea {
  background: rgba(4, 7, 12, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 0.6rem 0.7rem;
  font: inherit;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

.field input:hover,
.field select:hover,
.field textarea:hover,
.chat-compose textarea:hover {
  border-color: rgba(224, 122, 61, 0.35);
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.chat-compose textarea:focus {
  border-color: rgba(224, 122, 61, 0.65);
  box-shadow: 0 0 0 3px rgba(224, 122, 61, 0.15);
  outline: none;
}

.field input::placeholder,
.field textarea::placeholder,
.chat-compose textarea::placeholder {
  color: rgba(139, 149, 165, 0.75);
}

.ability-grid-form {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.4rem;
}

.gear-choices {
  margin-bottom: 0.5rem;
}

.chat-log {
  flex: 1;
  overflow: auto;
  padding: 0.85rem 0.95rem;
  background: rgba(6, 9, 14, 0.55);
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.06);
  min-height: 280px;
  max-height: calc(100vh - 260px);
}

.chat-msg {
  margin-bottom: 0.75rem;
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid transparent;
}

.chat-msg:last-child {
  margin-bottom: 0;
}

.chat-narrator {
  background: rgba(232, 139, 67, 0.045);
  border-color: var(--ledge);
  border-left-color: var(--torch);
}

.chat-body {
  line-height: 1.5;
  font-family: var(--font-body);
}

.chat-narrator .chat-body {
  font-family: var(--font-narrative);
  line-height: var(--line-height-narrative, 1.55);
  font-size: 1.02rem;
  color: var(--parchment);
}

.chat-system {
  background: rgba(255, 255, 255, 0.02);
  border-color: rgba(255, 255, 255, 0.04);
}

.chat-meta {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.3rem;
  font-size: 0.78rem;
}

.chat-who {
  font-weight: 600;
  color: var(--torch);
}

.chat-body {
  line-height: 1.5;
}

.chat-compose {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--ledge-soft);
}

.chat-compose textarea {
  width: 100%;
  min-height: 4.5rem;
  resize: vertical;
}

.chat-ask-host {
  border-left: 3px solid var(--torch);
  padding-left: 0.55rem;
  background: rgba(232, 168, 74, 0.08);
}

.chat-ask-host .chat-who {
  color: #f0c070;
}

.live-status {
  margin-left: auto;
  margin-right: 0.5rem;
}

.live-status.warn {
  color: #e8b86a;
}

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

.member-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.35rem;
}

.my-rooms-card {
  margin: 1rem 0;
}

.my-rooms-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.5rem;
}

.my-rooms-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--ledge-soft);
}

.chat-narrator .chat-who {
  color: var(--ember);
}

.chat-system .chat-who {
  color: var(--moss);
}

.chat-body {
  line-height: 1.5;
}

.chat-compose {
  margin-top: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.chat-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.status-dot.ok {
  background: var(--moss);
}

.status-dot.err {
  background: var(--blood);
}

.lang-switch {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  background: rgba(8, 11, 16, 0.45);
}

.lang-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 0.28rem 0.65rem;
  cursor: pointer;
}

.lang-btn.active,
.lang-btn[aria-pressed="true"] {
  background: var(--ember-soft);
  color: var(--torch);
}

.invite-card {
  margin: 0;
  padding: 0.85rem 0.95rem;
  border: 1px solid rgba(224, 122, 61, 0.28);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(224, 122, 61, 0.1), transparent 60%),
    rgba(8, 11, 16, 0.4);
}

.invite-code {
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--torch);
  padding: 0.15rem 0.35rem;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.25);
}

.share-hint {
  margin: 0.35rem 0 0;
}

.you-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.you-row #youLine {
  margin: 0;
}

.scene-card {
  margin: 0;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--ledge);
  border-radius: var(--radius-xs, 2px);
  background:
    radial-gradient(ellipse at 20% 0%, rgba(146, 119, 201, 0.07), transparent 50%),
    linear-gradient(180deg, rgba(29, 41, 53, 0.45), rgba(9, 14, 20, 0.65));
  box-shadow: var(--surface-frame, inset 1px 1px 0 rgba(255, 255, 255, 0.04));
  min-height: 4.5rem;
}

.scene-display {
  margin: 0.25rem 0 0.5rem;
  line-height: var(--line-height-narrative, 1.55);
  color: var(--text);
  font-family: var(--font-narrative);
  font-size: 1.02rem;
}

.scene-form .field,
.lore-form .field {
  margin-bottom: 0.4rem;
}

.lore-list {
  list-style: none;
  margin: 0.35rem 0;
  padding: 0;
  max-height: 10rem;
  overflow: auto;
}

.lore-list li {
  margin-bottom: 0.4rem;
  line-height: 1.35;
}

.lore-kind {
  opacity: 0.7;
  font-size: 0.75rem;
}

.recap-display {
  margin: 0.35rem 0;
  line-height: 1.4;
  white-space: pre-wrap;
}

.beats-list {
  margin: 0.35rem 0;
  max-height: 10rem;
  overflow: auto;
}

.beat-line {
  margin-bottom: 0.3rem;
  line-height: 1.3;
}

.beat-type {
  font-weight: 600;
}

.fronts-list {
  list-style: none;
  margin: 0.35rem 0;
  padding: 0;
}

.fronts-list li {
  margin-bottom: 0.4rem;
}

.meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.phase-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.28rem 0.7rem;
  border-radius: 999px;
  background: var(--ember-soft);
  color: var(--torch);
  border: 1px solid rgba(224, 122, 61, 0.3);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.ready-hint {
  margin: 0 0 0.35rem;
  padding: 0.55rem 0.7rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.ready-hint.ok {
  color: var(--moss);
  border-color: rgba(111, 168, 122, 0.3);
  background: var(--moss-soft);
}

.panel-header.tight {
  margin-bottom: 0.35rem;
}

.panel-header.tight h3 {
  margin: 0;
  font-size: 0.95rem;
}

.member-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  margin-top: 0.45rem;
  flex-shrink: 0;
}

.member-dot.ready {
  background: var(--moss);
  box-shadow: 0 0 0 3px var(--moss-soft);
}

.member-dot.wait {
  background: var(--ash);
}

.class-blurb {
  margin: -0.25rem 0 0.65rem;
  line-height: 1.4;
}

.ability-hint.ok {
  color: var(--moss);
}

.ability-hint.bad {
  color: var(--blood);
}

.typing-line {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.45rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.typing-dots {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--ember);
  animation: pulse-dot 1s var(--ease) infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 0.35; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1.1); }
}

.chat-tools {
  margin-top: 0.35rem;
  opacity: 0.75;
}

.compose-hint {
  flex: 1;
  text-align: right;
}

.chat-actions {
  flex-wrap: wrap;
}

.party-strip {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin: 0.65rem 0 0.85rem;
}

.party-chip {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.65rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.18);
}

.sheet-drawer {
  margin: 0;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-sm);
  padding: 0.15rem 0.7rem 0.35rem;
  background: rgba(8, 11, 16, 0.28);
}

.sheet-drawer summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--parchment);
  padding: 0.45rem 0;
  list-style: none;
}

.sheet-drawer summary::-webkit-details-marker {
  display: none;
}

.sheet-drawer summary::before {
  content: "";
  display: inline-block;
  width: 0.35rem;
  height: 0.35rem;
  margin-right: 0.5rem;
  border-right: 1.5px solid var(--torch);
  border-bottom: 1.5px solid var(--torch);
  transform: rotate(-45deg);
  transition: transform 0.15s var(--ease);
  vertical-align: 0.15rem;
}

.sheet-drawer[open] summary::before {
  transform: rotate(45deg);
  vertical-align: 0.05rem;
}

.sheet-body {
  margin-top: 0.5rem;
  line-height: 1.45;
  display: grid;
  gap: 0.35rem;
}

.desk-party-hint {
  margin: -0.25rem 0 0.55rem;
}

.desk-party-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.desk-party-chip {
  display: grid;
  gap: 0.1rem;
  text-align: left;
  padding: 0.45rem 0.6rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.03);
  color: inherit;
  cursor: pointer;
  min-width: 7.5rem;
}

.desk-party-chip:hover,
.desk-party-chip.is-selected {
  border-color: rgba(224, 122, 61, 0.55);
  background: rgba(224, 122, 61, 0.12);
}

.desk-party-chip.is-mine {
  box-shadow: inset 0 0 0 1px rgba(90, 170, 110, 0.35);
}

.desk-party-detail {
  margin-top: 0.65rem;
  padding-top: 0.65rem;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  display: grid;
  gap: 0.65rem;
}

.desk-threat-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  margin-bottom: 0.35rem;
}

.desk-front,
.desk-danger {
  margin-top: 0.55rem;
  padding-top: 0.45rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.desk-danger:first-of-type {
  border-top: none;
  padding-top: 0.25rem;
}

.desk-next-portent {
  margin-top: 0.2rem;
  color: var(--parchment);
}

.desk-gm-tools {
  margin-top: 0.75rem;
  padding-top: 0.65rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.desk-gm-heading {
  margin: 0 0 0.4rem;
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.desk-gm-form {
  margin-top: 0.35rem;
}

.desk-gm-form summary {
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--parchment);
}

.desk-form {
  display: grid;
  gap: 0.45rem;
  margin-top: 0.45rem;
}

.desk-move-chip {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.1rem;
  line-height: 1.2;
}

.desk-move-ability {
  font-size: 0.68rem;
  opacity: 0.75;
}

.move-card {
  display: grid;
  gap: 0.25rem;
  margin-top: 0.4rem;
  margin-right: 0.35rem;
  padding: 0.45rem 0.6rem;
  border-radius: var(--radius);
  border: 1px solid rgba(224, 122, 61, 0.35);
  background: var(--ember-soft);
  font-size: 0.85rem;
  max-width: 22rem;
}

.move-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.5rem;
}

.move-name {
  font-weight: 600;
}

.move-total {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 1.05rem;
}

.move-roll {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
}

.move-die {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.45rem;
  height: 1.45rem;
  padding: 0 0.25rem;
  border-radius: 0.3rem;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.8rem;
}

.move-mods {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.move-mod {
  padding: 0.1rem 0.3rem;
  border-radius: 0.25rem;
  background: rgba(255, 255, 255, 0.05);
}

.move-card.move-strong {
  border-color: rgba(90, 170, 110, 0.55);
  background: rgba(60, 120, 80, 0.22);
}

.move-card.move-weak {
  border-color: rgba(224, 160, 60, 0.55);
  background: rgba(140, 100, 30, 0.22);
}

.move-card.move-miss {
  border-color: rgba(190, 70, 70, 0.55);
  background: rgba(120, 40, 40, 0.28);
}

.move-band {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.move-effects {
  font-size: 0.78rem;
}

.move-needs {
  font-size: 0.75rem;
}

.open-table-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.host-strip .btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.2rem 0;
}

.room-lang {
  width: fit-content;
}

@media (max-width: 640px) {
  .compose-hint {
    display: none;
  }
  .ability-grid-form {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Keep the skin last: Play's component rules above intentionally stay easy to
   maintain, while this final layer owns the chosen visual language. */
.play-gate.panel {
  position: relative;
  border: 1px solid var(--ledge);
  border-radius: var(--radius-xs, 2px);
  background:
    linear-gradient(90deg, rgba(233, 226, 213, 0.02) 1px, transparent 1px),
    linear-gradient(rgba(233, 226, 213, 0.015) 1px, transparent 1px),
    linear-gradient(180deg, rgba(23, 33, 45, 0.55), transparent 35%),
    var(--pixel-panel);
  background-size: 12px 12px, 12px 12px, auto, auto;
  box-shadow:
    var(--surface-frame, inset 1px 1px 0 rgba(255, 255, 255, 0.05)),
    6px 8px 0 rgba(0, 0, 0, 0.38);
}
.play-hero { text-shadow: 2px 2px 0 #080c11; }
.play-hero::before { content: "◆"; margin-right: .55rem; color: var(--torch); font: .55em/1 var(--mono); vertical-align: .18em; }
.play-card {
  border: 1px solid var(--ledge);
  border-radius: var(--radius-xs, 2px);
  background: var(--color-surface-1, #0f161f);
  box-shadow:
    var(--surface-frame, inset 1px 1px 0 rgba(255, 255, 255, 0.05)),
    4px 5px 0 rgba(0, 0, 0, 0.32);
}
.play-card h2 { color: var(--parchment); font: 600 .85rem/1.35 var(--font-display); letter-spacing: .05em; text-transform: uppercase; }
.play-card h2::before { content: ""; }
.play-card h2::after { content: ""; }
.field input, .field select, .field textarea, .chat-compose textarea {
  border: 1px solid var(--ledge);
  border-radius: var(--radius-xs, 2px);
  box-shadow: inset 2px 2px 0 #05080c, inset -1px -1px rgba(255, 255, 255, 0.04);
}
.play-step-num, .phase-pill { border-radius: 0; }
.chat-log {
  border: 1px solid var(--ledge);
  border-radius: var(--radius-xs, 2px);
  box-shadow: inset 2px 2px 0 #05080c;
  background: rgba(9, 14, 20, 0.55);
}
.chat-msg { border-radius: 0; border-left: 2px solid var(--ledge); }
.chat-narrator { border-left-color: var(--torch); }


/* Phase 5 presence (gate + shared) */
.presence-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 0.4rem;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.35);
}
.presence-dot--connected { background: var(--moss, #6a9b6a); }
.presence-dot--reconnecting { background: var(--gold, #c9a227); }
.presence-dot--offline { background: var(--ash, #6b7380); }
.member-presence-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.45rem; }
.member-presence-item { display: flex; gap: 0.45rem; align-items: flex-start; }


/* Shared resolution card + connection banner (Play) */
.connection-banner-host:empty { display: none; }
.connection-banner {
  display: flex; align-items: center; gap: 0.55rem;
  padding: 0.45rem 0.85rem; border-bottom: 1px solid rgba(255,255,255,0.08);
  font-size: 0.85rem;
}
.connection-banner[hidden] { display: none !important; }
.connection-banner.is-reconnecting { background: rgba(201,162,39,0.12); }
.connection-banner.is-disconnected, .connection-banner.is-stale { background: rgba(180,60,60,0.14); }
.connection-banner-dot { width: 0.55rem; height: 0.55rem; border-radius: 50%; background: currentColor; }
.move-resolution-card {
  margin: 0.4rem 0; padding: 0.75rem 0.85rem;
  border: 1px solid rgba(255,255,255,0.12); border-radius: 2px;
  background: rgba(0,0,0,0.22);
}
.move-resolution-card.is-strong { border-color: rgba(90,170,110,0.55); }
.move-resolution-card.is-partial { border-color: rgba(224,160,60,0.55); }
.move-resolution-card.is-miss { border-color: rgba(190,70,70,0.55); }
.resolution-header { display: flex; justify-content: space-between; gap: 0.75rem; }
.resolution-outcome { display: flex; align-items: center; gap: 0.35rem; }
.resolution-roll { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.5rem; }
.resolution-die {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 1.7rem; height: 1.7rem; border: 1px solid rgba(255,255,255,0.16);
  background: rgba(0,0,0,0.35); font-family: ui-monospace, monospace;
}
.resolution-mods { display: inline-flex; gap: 0.25rem; flex-wrap: wrap; }
.resolution-mod { padding: 0.1rem 0.3rem; border: 1px solid rgba(255,255,255,0.1); font-size: 0.75rem; }
.resolution-changes { margin: 0.45rem 0 0; padding-left: 1.1rem; font-size: 0.82rem; }
