:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #ece7df;
  color: #253246;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  overflow: hidden;
}

button {
  font: inherit;
}

.app-shell {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  min-height: 100vh;
}

.topbar {
  align-items: center;
  background: #f8f6f1;
  border-bottom: 1px solid #d8d1c5;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  padding: 10px 20px;
}

.topbar-title {
  align-items: baseline;
  display: flex;
  gap: 10px;
  min-width: 0;
}

.topbar-title span {
  color: #65748b;
  font-size: 0.95rem;
  font-weight: 700;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  font-size: clamp(1.1rem, 2vw, 1.45rem);
  line-height: 1.05;
  margin-bottom: 0;
}

h2 {
  font-size: 1.05rem;
}

h3 {
  border-top: 1px solid #d7dce4;
  font-size: 0.82rem;
  margin: 18px 0 8px;
  padding-top: 12px;
  text-transform: uppercase;
}

.primary {
  background: #2f4159;
  border: 0;
  border-radius: 6px;
  color: white;
  cursor: pointer;
  min-height: 40px;
  padding: 0 14px;
}

.secondary {
  background: #fffdfa;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  color: #334155;
  cursor: pointer;
  min-height: 40px;
  padding: 0 14px;
}

.help-link {
  background: transparent;
  border: 0;
  color: #0f766e;
  cursor: pointer;
  font-weight: 800;
  min-height: 32px;
  padding: 0 4px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.secondary:disabled {
  cursor: default;
  opacity: 0.45;
}

.topbar-actions {
  align-items: center;
  display: flex;
  gap: 8px;
}

.primary:disabled {
  cursor: default;
  opacity: 0.45;
}

.layout {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(220px, 280px) minmax(360px, 1fr) minmax(220px, 300px);
  grid-template-rows: auto auto minmax(0, 1fr);
  min-height: 0;
  overflow: hidden;
  padding: 16px;
  flex: 1;
}

.guide-panel {
  background: #fffdfa;
  border: 1px solid #d8d1c5;
  border-radius: 8px;
  display: grid;
  gap: 18px;
  grid-column: 1 / -1;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  max-height: 27dvh;
  overflow: auto;
  padding: 16px 18px;
}

.guide-panel[hidden] {
  display: none;
}

.reference-panel {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  display: grid;
  gap: 18px;
  grid-column: 1 / -1;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  max-height: 23dvh;
  overflow: auto;
  padding: 14px 18px;
}

.reference-panel[hidden] {
  display: none;
}

.guide-panel h2,
.reference-panel h2 {
  font-size: 0.95rem;
  margin-bottom: 8px;
}

.guide-panel p {
  color: #475569;
  font-size: 0.92rem;
  line-height: 1.35;
  margin-bottom: 8px;
}

.guide-panel ol,
.guide-panel ul,
.reference-panel ul {
  color: #475569;
  font-size: 0.92rem;
  line-height: 1.35;
  margin: 0;
  padding-left: 20px;
}

.guide-panel li + li,
.reference-panel li + li {
  margin-top: 4px;
}

.legend {
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 12px;
}

.legend span {
  align-items: center;
  color: #475569;
  display: flex;
  font-size: 0.86rem;
  gap: 8px;
}

.legend-swatch {
  align-items: center;
  display: inline-flex;
  flex: 0 0 auto;
  font-size: 0.7rem;
  font-style: normal;
  font-weight: 900;
  height: 20px;
  justify-content: center;
  width: 20px;
}

.legend-swatch.legal {
  background: rgb(20 184 166 / 0.2);
  border: 1.25px solid rgb(15 118 110 / 0.98);
  border-radius: 4px;
}

.legend-swatch.marked {
  background: rgb(255 255 255 / 0.88);
  border: 1.5px solid #2f4159;
  border-radius: 50%;
  color: #1f2a3a;
}

.legend-swatch.collected {
  background: rgb(250 204 21 / 0.38);
  border: 1.5px solid #b7791f;
  border-radius: 50%;
}

.legend-swatch.defeated {
  background: rgb(74 222 128 / 0.4);
  border: 1.5px solid #15803d;
  border-radius: 50%;
}

.panel {
  background: #fffdfa;
  border: 1px solid #d8d1c5;
  border-radius: 8px;
  min-height: 0;
  overflow: auto;
  padding: 16px;
}

.hero-panel ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.quest-portrait {
  aspect-ratio: 1;
  background: #f8f6f1;
  border: 1px solid #d8d1c5;
  border-radius: 8px;
  margin: 0 0 12px;
  overflow: hidden;
  position: relative;
}

.quest-portrait img {
  display: block;
  max-width: none;
  position: absolute;
}

.hero-panel li {
  align-items: center;
  border-bottom: 1px solid #ece7df;
  display: flex;
  justify-content: space-between;
  min-height: 34px;
}

.equipment-list button {
  background: transparent;
  border: 0;
  color: #334155;
  cursor: pointer;
  font-weight: 700;
  padding: 0;
  text-align: left;
}

.equipment-list button.selected {
  color: #0f766e;
}

.equipment-list button:disabled {
  color: #758195;
  cursor: default;
}

.hero-panel li span,
.muted {
  color: #758195;
}

.help-disclosure {
  border-bottom: 1px solid #ece7df;
  padding-bottom: 10px;
}

.help-disclosure summary,
.objective-box summary {
  color: #334155;
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 800;
}

.help-disclosure p {
  color: #475569;
  font-size: 0.9rem;
  line-height: 1.35;
  margin: 8px 0 0;
}

.campaign-progress {
  border-bottom: 1px solid #ece7df;
  padding: 10px 0;
}

.campaign-progress summary {
  color: #334155;
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 800;
}

.campaign-progress ol {
  display: grid;
  gap: 3px;
  list-style: none;
  margin: 10px 0 0;
  max-height: 190px;
  overflow: auto;
  padding: 0;
}

.campaign-progress li {
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  min-height: 30px;
  overflow: hidden;
}

.campaign-progress li.current {
  background: #eef6ff;
  border-color: #93c5fd;
}

.campaign-progress li.complete {
  background: #dcfce7;
  border-color: #86efac;
}

.campaign-progress button {
  align-items: center;
  background: transparent;
  border: 0;
  color: inherit;
  cursor: pointer;
  display: grid;
  gap: 6px;
  grid-template-columns: auto minmax(0, 1fr) auto;
  min-height: 30px;
  padding: 4px 6px;
  text-align: left;
  width: 100%;
}

.campaign-progress button:disabled {
  cursor: default;
}

.campaign-progress span,
.campaign-progress em {
  color: #64748b;
  font-size: 0.68rem;
  font-style: normal;
  font-weight: 800;
  text-transform: uppercase;
}

.campaign-progress strong {
  color: #334155;
  font-size: 0.76rem;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.queued-page-card {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  display: grid;
  gap: 4px;
  margin: 10px 0;
  padding: 10px;
}

.queued-page-card strong {
  color: #334155;
  font-size: 0.88rem;
}

.queued-page-card span {
  color: #64748b;
  font-size: 0.78rem;
  overflow-wrap: anywhere;
}

.dungeon-picker {
  display: grid;
  gap: 6px;
}

.dungeon-picker button {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  color: #334155;
  min-height: 34px;
  padding: 4px 8px;
  text-align: left;
}

.dungeon-picker button.current {
  border-color: #2f4159;
  box-shadow: inset 3px 0 0 #2f4159;
}

.dungeon-picker button.complete {
  background: #dcfce7;
  border-color: #86efac;
}

.dungeon-picker button.untranscribed {
  background: #f3f4f6;
  color: #6b7280;
}

.dungeon-picker button:disabled {
  opacity: 0.45;
}

.sheet-stage {
  align-items: start;
  display: grid;
  gap: 8px;
  grid-template-rows: minmax(0, 1fr) auto;
  justify-content: stretch;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  width: 100%;
}

.queued-sheet-stage {
  grid-template-rows: minmax(0, 1fr);
}

.queued-pdf-shell {
  background: #f8f6f1;
  border: 1px solid #c7bfaf;
  border-radius: 8px;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  width: 100%;
}

.queued-pdf-shell iframe,
.queued-pdf-shell img {
  border: 0;
  display: block;
  height: 100%;
  object-fit: contain;
  width: 100%;
}

.sheet-art {
  background: #f8f6f1;
  border: 1px solid #c7bfaf;
  border-radius: 8px;
  height: 100%;
  justify-self: center;
  max-width: 100%;
  overflow: hidden;
  position: relative;
  width: auto;
}

.sheet-art img,
.sheet-strip img {
  display: block;
  max-width: none;
  position: absolute;
}

.sheet-context-strips {
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr);
  width: 100%;
}

.sheet-strip {
  background: #f8f6f1;
  border: 1px solid #d8d1c5;
  border-radius: 6px;
  min-height: 58px;
  overflow: hidden;
  position: relative;
}

.overlay-note {
  background: rgb(47 65 89 / 0.92);
  border-radius: 6px;
  color: white;
  font-size: 0.8rem;
  left: 12px;
  padding: 8px 10px;
  position: absolute;
  top: 12px;
}

.dungeon-overlay {
  position: absolute;
}

.dungeon-complete-mark {
  align-items: center;
  background: rgb(22 101 52 / 0.13);
  border: 2px solid rgb(22 101 52 / 0.72);
  border-radius: 8px;
  color: #14532d;
  display: flex;
  justify-content: center;
  pointer-events: none;
  position: absolute;
}

.dungeon-complete-mark span {
  background: rgb(240 253 244 / 0.94);
  border: 1px solid rgb(22 101 52 / 0.35);
  border-radius: 999px;
  box-shadow: 0 2px 8px rgb(15 23 42 / 0.12);
  font-size: 0.82rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  padding: 6px 10px;
  text-transform: uppercase;
}

.cell-hotspot {
  align-items: center;
  background: transparent;
  border: 1px solid transparent;
  color: #1f2a3a;
  display: flex;
  font-size: clamp(0.55rem, 1.2vw, 0.95rem);
  font-weight: 900;
  justify-content: center;
  line-height: 1;
  padding: 0;
  position: absolute;
}

.cell-hotspot.legal {
  background: rgb(20 184 166 / 0.2);
  border: 1.25px solid rgb(15 118 110 / 0.98);
  border-radius: 4px;
  box-shadow: 0 0 0 1px rgb(255 255 255 / 0.65) inset;
  cursor: pointer;
}

.cell-hotspot.marked {
  background: rgb(255 255 255 / 0.88);
  border: 1.5px solid #2f4159;
  border-radius: 50%;
}

.cell-hotspot.collected {
  background: rgb(250 204 21 / 0.38);
  border: 1.5px solid #b7791f;
  border-radius: 50%;
}

.cell-hotspot.defeated {
  background: rgb(74 222 128 / 0.4);
  border: 1.5px solid #15803d;
  border-radius: 50%;
}

.cell-hotspot:disabled {
  pointer-events: none;
}

.dice-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 44px;
}

.dev-panel {
  align-items: end;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 6px;
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr auto;
  margin: 12px 0 0;
  padding: 8px;
}

.dev-panel label {
  color: #9a3412;
  display: grid;
  font-size: 0.75rem;
  font-weight: 800;
  gap: 4px;
  text-transform: uppercase;
}

.dev-panel input {
  border: 1px solid #fdba74;
  border-radius: 4px;
  color: #431407;
  min-height: 32px;
  padding: 4px 8px;
}

.dev-panel button {
  background: #c2410c;
  border: 0;
  border-radius: 4px;
  color: white;
  min-height: 32px;
  padding: 0 10px;
}

.die {
  align-items: center;
  border-radius: 6px;
  display: inline-flex;
  font-weight: 800;
  height: 38px;
  justify-content: center;
  width: 38px;
}

button.die {
  border: 0;
  cursor: pointer;
}

.die.good {
  background: white;
  border: 2px solid #7f8da3;
}

.die.evil {
  background: #202936;
  color: white;
}

.die.selected {
  outline: 3px solid #d98b2b;
  outline-offset: 2px;
}

.die.spent {
  cursor: default;
  opacity: 0.35;
}

.status {
  color: #6d4b27;
  margin: 10px 0 0;
}

.monster-list {
  display: grid;
  gap: 6px;
  margin: 0 0 14px;
}

.inventory-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.inventory-list span:not(.muted) {
  background: #fef3c7;
  border: 1px solid #fbbf24;
  border-radius: 999px;
  color: #78350f;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 4px 8px;
}

.inventory-list button {
  background: #fffdfa;
  border: 1px solid #d8d1c5;
  border-radius: 6px;
  color: #334155;
  cursor: pointer;
  font-size: 0.8rem;
  min-height: 28px;
  padding: 0 8px;
}

.monster-list span {
  background: #eef2f7;
  border-radius: 6px;
  color: #334155;
  font-size: 0.82rem;
  padding: 6px 8px;
}

.health-meter {
  background: #e5e7eb;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  height: 12px;
  overflow: hidden;
}

.health-meter span {
  background: #2f855a;
  display: block;
  height: 100%;
}

.danger {
  background: #fee2e2;
  border: 1px solid #fca5a5;
  border-radius: 6px;
  color: #991b1b;
  padding: 8px;
}

.pending-attack {
  background: #fff7ed;
  border: 1px solid #fdba74;
  border-radius: 6px;
  margin: 12px 0;
  padding: 10px;
}

.effect-panel {
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: 6px;
  display: grid;
  gap: 8px;
  margin: 12px 0;
  padding: 10px;
}

.effect-panel p {
  color: #075985;
  font-size: 0.86rem;
  font-weight: 800;
  margin: 0;
}

.effect-panel div {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.effect-panel button {
  background: #0369a1;
  border: 0;
  border-radius: 4px;
  color: white;
  cursor: pointer;
  min-height: 32px;
  padding: 0 10px;
}

.pending-attack p {
  color: #9a3412;
  font-weight: 800;
  margin-bottom: 8px;
}

.pending-attack ul {
  color: #9a3412;
  font-size: 0.9rem;
  line-height: 1.35;
  margin: 0 0 10px;
  padding-left: 20px;
}

.pending-attack button {
  background: #c2410c;
  border: 0;
  border-radius: 4px;
  color: white;
  min-height: 32px;
  padding: 0 10px;
}

.reward-panel {
  background: #ecfdf5;
  border: 1px solid #6ee7b7;
  border-radius: 6px;
  margin: 12px 0;
  padding: 10px;
}

.reward-panel h3 {
  border-top: 0;
  color: #065f46;
  margin: 0 0 6px;
  padding-top: 0;
}

.reward-panel p {
  color: #065f46;
  font-size: 0.9rem;
  line-height: 1.35;
}

.reward-panel div {
  display: grid;
  gap: 8px;
}

.reward-panel button {
  background: #fffdfa;
  border: 1px solid #6ee7b7;
  border-radius: 6px;
  color: #064e3b;
  cursor: pointer;
  display: grid;
  gap: 3px;
  padding: 8px;
  text-align: left;
}

.reward-panel button span,
.reward-panel button small {
  color: #047857;
}

.segmented {
  display: flex;
  gap: 6px;
}

.segmented button {
  background: #fffdfa;
  border: 1px solid #fdba74;
  color: #9a3412;
  min-width: 34px;
}

.segmented button.selected {
  background: #c2410c;
  color: white;
}

.objective-box {
  background: #eef6ff;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  margin: 0 0 14px;
  padding: 10px;
}

.objective-box p {
  color: #1e3a8a;
  font-size: 0.9rem;
  line-height: 1.35;
  margin: 8px 0 6px;
}

.objective-box .muted {
  color: #475569;
}

.success {
  background: #dcfce7;
  border: 1px solid #86efac;
  border-radius: 6px;
  color: #166534;
  padding: 8px;
}

.xp-total {
  font-size: 1.35rem;
  font-weight: 800;
}

.log {
  color: #566174;
  margin-bottom: 0;
  padding-left: 20px;
}

@media (max-width: 980px) {
  body {
    overflow: auto;
  }

  .app-shell {
    height: auto;
  }

  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: none;
    overflow: visible;
  }

  .guide-panel {
    grid-template-columns: 1fr;
    max-height: none;
  }

  .reference-panel {
    grid-template-columns: 1fr;
    max-height: none;
  }

  .panel {
    overflow: visible;
  }

  .sheet-stage {
    overflow: visible;
  }

  .sheet-art {
    height: auto;
    width: 100%;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

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

  .topbar-actions button {
    flex: 1 1 136px;
  }
}
