:root {
  color-scheme: dark;
  --bg: #17120e;
  --card: #231b15;
  --edge: #43342a;
  --text: #f0e6d8;
  --muted: #b5a48f;
  --accent: #d9a441;
  --accent-ink: #231605;
  --bad: #f08a7a;
  --good: #8fcf9b;
  --grid: rgba(255, 255, 255, 0.14);
  --ink-edge: #120d09;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 Georgia, "Times New Roman", serif;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--edge);
}

h1 { margin: 0; font-size: 1.3rem; color: var(--accent); white-space: nowrap; }
h2 { margin: 0; font-size: 1.4rem; }
h3 { margin: 0 0 8px; font-size: 1.05rem; color: var(--accent); }

#account { display: flex; align-items: center; gap: 12px; min-width: 0; }
#username { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

main { max-width: 1100px; margin: 0 auto; padding: 16px; }

.card {
  background: var(--card);
  border: 1px solid var(--edge);
  border-radius: 8px;
  padding: 16px;
}

.narrow { max-width: 460px; margin: 48px auto; }

.titlebar { display: flex; flex-wrap: wrap; align-items: baseline; gap: 12px; margin-bottom: 16px; }

#role, .muted { color: var(--muted); }

.live { margin-left: auto; font-size: 0.85rem; color: var(--muted); }
.live.on { color: var(--good); }

.grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 16px; }
.column { display: grid; gap: 16px; align-content: start; }

ul, ol { list-style: none; margin: 0; padding: 0; }

.rows li {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 12px;
  padding: 6px 8px;
  border-top: 1px solid var(--edge);
}

.rows li:first-child { border-top: 0; }
.rows li.current { background: #3a2c1c; border-radius: 4px; }

.log-card { display: flex; flex-direction: column; min-height: 420px; }

#log { flex: 1; max-height: 56vh; overflow-y: auto; margin-bottom: 12px; }
#log li { padding: 4px 0; white-space: pre-wrap; overflow-wrap: anywhere; }
#log li.private { color: var(--muted); font-style: italic; }

label { display: block; margin-bottom: 4px; color: var(--muted); }

.inline { display: flex; gap: 8px; }

input {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--edge);
  border-radius: 6px;
  font: inherit;
}

button, .button {
  display: inline-block;
  padding: 8px 14px;
  color: var(--accent-ink);
  background: var(--accent);
  border: 0;
  border-radius: 6px;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

#logout { flex: none; white-space: nowrap; color: var(--text); background: transparent; border: 1px solid var(--edge); font-weight: 400; }
#campaign-list button { width: 100%; margin-top: 8px; }

nav { display: flex; gap: 8px; margin-bottom: 16px; }

button.tab { color: var(--muted); background: transparent; border: 1px solid var(--edge); font-weight: 400; }
button.tab.active, button.tab[aria-current="page"] { color: var(--accent-ink); background: var(--accent); }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }

button.quiet { color: var(--text); background: transparent; border: 1px solid var(--edge); font-weight: 400; text-align: left; }
button:disabled { opacity: 0.5; cursor: default; }

.play { margin-bottom: 16px; border-color: var(--accent); }
.stack { display: grid; gap: 8px; margin-bottom: 12px; }
.stack p, .stack h4 { margin: 0; }
.buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
h4 { margin: 0 0 6px; font-size: 1rem; }
.picker { display: grid; gap: 8px; padding: 12px; border: 1px solid var(--edge); border-radius: 6px; }
.picker h4 { margin: 0; }
.actions { display: grid; gap: 6px; }
.actions button { width: 100%; }
.check { display: flex; align-items: center; gap: 8px; margin: 6px 0 0; color: var(--text); }
.check input { flex: none; width: 18px; height: 18px; }
select {
  min-width: 0;
  padding: 8px 10px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--edge);
  border-radius: 6px;
  font: inherit;
}
details { color: var(--muted); }
summary { cursor: pointer; }
details label { margin-top: 8px; }
details input { width: 100%; }
#play-note:empty, #dm-note:empty, #map-note:empty { display: none; }
#watch-card { margin-bottom: 16px; }
.handout-picture { max-width: 100%; height: auto; display: block; }
a { color: var(--accent); }
#dm-note { position: sticky; top: 0; z-index: 3; padding: 8px; background: var(--card); border: 1px solid var(--edge); border-radius: 6px; }
#dm-scene button { margin: 4px 4px 4px 0; }
#dm-scene p { margin: 4px 0; }
#dm-cast button, #dm-quests select { padding: 2px 8px; }
#manage-body details { padding: 8px 0; border-top: 1px solid var(--edge); }
#manage-body summary { color: var(--text); }
#manage-body select, #manage-body input:not([type="checkbox"]) { width: 100%; flex: none; }
#manage-body .inline input { flex: 1; width: auto; }
#manage-body .inline select { width: auto; }
.gear-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 4px 0; }
.gear-row button { flex: none; padding: 2px 10px; }
#story-titles, #story-sessions { max-height: 280px; overflow-y: auto; }
#story-search, #rules-search { margin-bottom: 8px; }
#story-reader { max-height: 75vh; overflow-y: auto; }
.story-hit { padding: 8px 0; border-top: 1px solid var(--edge); }
.story-hit p { margin: 4px 0; }
.map-scroll { max-height: 70vh; margin: 12px 0; overflow: auto; border: 1px solid var(--edge); border-radius: 6px; }
.map {
  position: relative;
  background-color: #2b2219;
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 40px 40px;
  cursor: crosshair;
}
.map::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
}
#map-picture { position: absolute; max-width: none; }
#map-fog { position: absolute; top: 0; left: 0; pointer-events: none; }
.map.painting { touch-action: none; cursor: cell; }
.map.painting button.token { pointer-events: none; }
#map-tokens { position: absolute; inset: 0; z-index: 1; }
#map-tokens > * { position: absolute; width: 40px; height: 40px; }
button.token {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 2px solid var(--ink-edge);
  border-radius: 50%;
  font: 600 0.8rem/1 Georgia, serif;
  color: #fff;
  background: #7d3226;
  overflow: hidden;
}
button.token.pc { color: var(--accent-ink); background: var(--accent); }
button.token.current { box-shadow: 0 0 0 3px var(--good); }
button.token.selected { outline: 3px solid #fff; outline-offset: 1px; }
button.token.concealed { opacity: 0.6; border-style: dashed; }
button.token.in-tray { width: auto; height: auto; padding: 6px 12px; border-radius: 6px; font-size: 0.9rem; }
.map-target { border: 3px dashed #fff; border-radius: 4px; pointer-events: none; }
#requests, #knack, #create-card, #level-panel { margin-bottom: 16px; }
.loot-item { padding: 8px 0; margin: 0; border-top: 1px solid var(--edge); }
.score-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; }
.score-grid select, #create-body select, #create-body input:not([type="checkbox"]), #tools-body select { width: 100%; }
.skill-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0 12px; }
textarea {
  width: 100%;
  padding: 8px 10px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--edge);
  border-radius: 6px;
  font: inherit;
  resize: vertical;
}
[hidden] { display: none !important; }
.stack > label { margin-bottom: 0; }
.short { flex: 0 0 5.5rem; }
.dm-controls { padding-top: 12px; margin-top: 12px; border-top: 1px solid var(--edge); }
.dm-result { padding-top: 8px; margin-top: 12px; border-top: 1px solid var(--edge); }
.dm-result p { margin: 0; }
#dm-party button { padding: 2px 10px; }
#dm-note { margin: 0 0 12px; }
#dm-preview { margin-bottom: 12px; }
.sheet-section { padding: 8px 0; border-top: 1px solid var(--edge); }
.sheet-section p { margin: 0; }
.sheet-rolls { margin-top: 16px; }
#check-what { flex: 1; }
code { color: var(--accent); font-family: inherit; }
code.block { display: block; color: var(--text); font-family: Consolas, monospace; white-space: pre-wrap; }

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

.error { min-height: 1.5em; margin: 6px 0 0; color: var(--bad); }

@media (max-width: 760px) {
  .grid { grid-template-columns: minmax(0, 1fr); }
  #log { max-height: 44vh; }
}
#whispers { max-height: 220px; margin: 0; padding: 0; overflow-y: auto; list-style: none; }
#whispers li { padding: 4px 0; }
