:root {
  color-scheme: dark;
  --bg: #16130f;
  --panel: #211c16;
  --panel2: #2a241c;
  --line: #3d3428;
  --ink: #eadfc8;
  --muted: #a8977a;
  --gold: #d9a441;
  --red: #c9573f;
  --green: #7fae5b;
  --blue: #5b9bd5;
  --violet: #9b7fd6;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 system-ui, sans-serif; }
header {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 10px 18px; background: linear-gradient(#241e17, #1b1712); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.brand { font-family: var(--serif); font-size: 22px; letter-spacing: .5px; }
.sigil { color: var(--gold); }
.clock { font-family: var(--serif); font-size: 16px; color: var(--gold); min-width: 140px; }
nav { display: flex; gap: 4px; flex-wrap: wrap; }
nav button {
  background: transparent; color: var(--muted); border: 1px solid transparent; border-radius: 6px;
  padding: 6px 12px; font: inherit; cursor: pointer;
}
nav button:hover { color: var(--ink); }
nav button.active { color: var(--ink); border-color: var(--line); background: var(--panel2); }
.live { margin-left: auto; color: var(--green); font-size: 12px; }
.live.stale { color: var(--muted); }
.logos-light { margin-left: auto; color: #e0523f; font-size: 12px; animation: pulse 1.6s ease-in-out infinite; }
.logos-light:not([hidden]) + .live { margin-left: 12px; }
@keyframes pulse { 50% { opacity: .45; } }
.feedback-open { background: transparent; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 4px 10px; font: inherit; font-size: 12px; cursor: pointer; }
.feedback-open:hover { color: var(--ink); }
#feedback { background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; width: min(480px, calc(100vw - 32px)); padding: 16px; }
#feedback::backdrop { background: #0008; }
#feedback h3 { margin: 0 0 6px; font-family: var(--serif); color: var(--gold); }
#feedback textarea, #feedback input { display: block; width: 100%; margin: 8px 0; background: var(--bg); color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: 8px; font: inherit; }
.feedback-row { display: flex; gap: 8px; align-items: center; }
.feedback-row span { margin-right: auto; }
.feedback-row button { background: var(--panel2); color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: 6px 14px; font: inherit; cursor: pointer; }
main { padding: 16px 18px; }
.tab { display: none; }
.tab.active { display: block; }
@media (max-width: 900px) { #stage { height: calc(100dvh - 150px); min-height: 420px; } }

/* A person's or a building's card over the stage; on a phone, along the bottom. */
.stage-card { position: absolute; top: 50px; right: 12px; width: 370px; max-height: calc(100% - 70px); overflow: auto; background: rgba(33,28,22,.96); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; font-size: 13px; line-height: 1.4; box-shadow: 0 6px 24px rgba(0,0,0,.45); }
.stage-card h3 { margin: 10px 0 3px; font-size: 13px; color: var(--gold); }
.stage-card .who { display: flex; gap: 10px; align-items: center; }
.stage-card .who img, .stage-card .who .face { width: 52px; height: 52px; flex: none; border-radius: 50%; border: 3px solid var(--line); object-fit: cover; display: grid; place-items: center; background: var(--panel2); font-size: 24px; }
.stage-card .why { font-style: italic; color: var(--ink); }
.stage-card h3 .face { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); object-fit: cover; vertical-align: middle; display: inline-grid; place-items: center; font-size: 11px; background: var(--panel2); }
.stage-card .acts { display: flex; gap: 6px; margin: 8px 0; }
.stage-card .acts button { background: var(--panel2); border: 1px solid var(--line); color: var(--ink); border-radius: 6px; padding: 3px 10px; cursor: pointer; font-size: 12px; }
.stage-card ul.plain li { margin: 3px 0; }
.stage-card .tabs { display: flex; flex-wrap: wrap; gap: 2px; border-bottom: 1px solid var(--line); margin: 4px 0 6px; }
.stage-card .tabs button { background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted); padding: 4px 7px; cursor: pointer; font-size: 12px; }
.stage-card .tabs button.on { color: var(--ink); border-bottom-color: var(--gold); }
.stage-card table.mini { width: 100%; border-collapse: collapse; margin: 2px 0; }
.stage-card table.mini td { padding: 1px 4px; border-bottom: 1px solid rgba(61,52,40,.5); vertical-align: middle; }
.stage-card table.mini td.n { text-align: right; font-variant-numeric: tabular-nums; }
.stage-card table.mini .bar { min-width: 90px; }
.stage-card tr.skill { cursor: pointer; }
.stage-card tr.skill:hover td, .stage-card tr.skill.open td { background: rgba(217,164,65,.08); }
.stage-card tr.skill-info td { padding: 4px 8px 8px; font-size: 12px; line-height: 1.45; }
.stage-card tr.skill-info div + div { margin-top: 3px; }
.stage-hint { position: absolute; left: 50%; top: 14px; transform: translateX(-50%); max-width: calc(100% - 24px); background: rgba(33,28,22,.94); border: 1px solid var(--gold); color: var(--ink); border-radius: 10px; padding: 7px 12px; font-size: 13px; }
.stage-hint button { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 15px; margin-left: 6px; }
.stage-card .card-whisper textarea { width: 100%; background: var(--panel2); color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: 5px; font: inherit; resize: vertical; }
.stage-card .card-whisper button { margin-top: 4px; background: var(--panel2); border: 1px solid #9b7fd6; color: var(--ink); border-radius: 6px; padding: 3px 10px; cursor: pointer; }
/* One's own people and a search, low on the left of the map. */
.stage-hud { position: absolute; left: 12px; bottom: 36px; width: 240px; display: flex; flex-direction: column-reverse; gap: 6px; }
#stage-find { width: 100%; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line); background: rgba(33,28,22,.92); color: var(--ink); font-size: 13px; }
#stage-found { list-style: none; margin: 0; padding: 4px; background: rgba(33,28,22,.96); border: 1px solid var(--line); border-radius: 8px; max-height: 260px; overflow: auto; }
#stage-found li, #stage-mine button { display: flex; align-items: center; gap: 8px; cursor: pointer; }
#stage-found li { padding: 4px 6px; border-radius: 6px; font-size: 13px; }
#stage-found li:hover, #stage-found li.on { background: rgba(217,164,65,.15); }
#stage-found .muted { font-size: 11px; }
#stage-mine { display: flex; gap: 6px; flex-wrap: wrap; }
#stage-mine button { padding: 2px 8px 2px 2px; border-radius: 999px; border: 1px solid var(--line); background: rgba(33,28,22,.92); color: var(--ink); font-size: 12px; }
#stage-mine button.on { border-color: var(--gold); }
.stage-hud .face { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--line); object-fit: cover; display: grid; place-items: center; background: var(--panel2); font-size: 11px; flex: none; }
@media (max-width: 700px) {
  .stage-hud { left: 8px; right: 8px; bottom: 8px; width: auto; }
  .stage-card:not([hidden]) ~ .stage-hud { display: none; }
  /* The tabs keep to one row that scrolls, so the map has the screen. */
  nav#tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; max-width: 100%; }
  nav#tabs button { flex: none; }
  header { gap: 4px 10px; padding: 8px 10px; }
  .brand { font-size: 18px; }
  .clock { font-size: 13px; min-width: 0; }
}
.stage-card .whisper-now { background: #2a2338; color: #e4dcf3; border-radius: 8px; padding: 6px 9px; margin: 2px 0 6px; }
@media (max-width: 700px) { .stage-card { top: auto; bottom: 8px; left: 8px; right: 8px; width: auto; max-height: 55%; } }
.stage-wrap { position: relative; min-width: 0; }
#stage { display: block; width: 100%; height: calc(100vh - 96px); border: 1px solid var(--line); border-radius: 10px; touch-action: none; cursor: grab; }
/* The map fills what the header leaves, whatever its height, so the page never scrolls under it. */
body:has(#tab-map.active) { height: 100dvh; display: flex; flex-direction: column; }
body:has(#tab-map.active) main { flex: 1; min-height: 0; display: flex; }
#tab-map.active { flex: 1; min-height: 0; display: flex; }
#tab-map .stage-wrap { flex: 1; }
body:has(#tab-map.active) #stage { height: 100%; min-height: 0; }

h3 { font-family: var(--serif); font-weight: normal; margin: 0 0 8px; color: var(--gold); }
.ev { padding: 6px 0; border-bottom: 1px solid #2e271e; display: flex; gap: 8px; }
.ev .t { color: var(--muted); font-size: 12px; min-width: 64px; }
.ev .i { width: 18px; text-align: center; }
.ev.say .x { font-style: italic; color: #d8cdb5; }
.ev.failed .x { color: #b98b7a; }
.ev.built .x, .ev.raised .x { color: var(--green); }
.ev.raid .x, .ev.combat .x, .ev.death .x { color: var(--red); }
.ev.trade .x, .ev.debt_paid .x { color: var(--gold); }

.people { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
#graveyard { margin-top: 18px; }
#graveyard summary { cursor: pointer; opacity: .75; padding: 6px 0; }
#graveyard .card { opacity: .7; }
ul.changes { list-style: none; padding-left: 0; }
.changes li { padding: 3px 0; line-height: 1.4; }
.changes .muted { display: inline-block; min-width: 2.2em; font-variant-numeric: tabular-nums; }
details.fold summary, #logos-full summary { cursor: pointer; opacity: .75; padding: 10px 0 6px; }
#person details.fold summary { opacity: 1; font-family: var(--serif); color: var(--gold); font-size: 1.17em; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; cursor: pointer; border-top: 3px solid var(--muted); }
.card:hover { background: var(--panel2); }
.card h4 { margin: 0; font-family: var(--serif); font-size: 17px; }
.card .meta { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.card .doing { margin: 6px 0; }
.card .why { color: #cdbf9f; font-style: italic; font-size: 13px; }
.bars { display: grid; grid-template-columns: 52px 1fr; gap: 2px 8px; font-size: 11px; color: var(--muted); align-items: center; margin: 6px 0; }
.bar { height: 6px; background: #3a3127; border-radius: 3px; overflow: hidden; }
.bar > i { display: block; height: 100%; }
.person { margin-top: 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; }
.person h2 { font-family: var(--serif); font-weight: normal; margin: 0; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; margin-top: 10px; }
.chip { display: inline-block; padding: 2px 8px; margin: 2px; border-radius: 999px; background: var(--panel2); border: 1px solid var(--line); font-size: 12px; }
.thought { border-left: 2px solid var(--line); padding: 4px 10px; margin: 6px 0; }
.thought .a { font-size: 12px; color: var(--muted); }
.thought.fail { border-color: var(--red); }
.whisper .fail { color: var(--red); font-size: 0.9em; }
.plan { white-space: pre-wrap; background: var(--panel2); padding: 8px 10px; border-radius: 6px; }
ul.plain { margin: 4px 0; padding-left: 18px; }
ul.note { margin: 3px 0 0; padding-left: 16px; }
ul.note li { margin: 2px 0; }
.close { float: right; background: none; border: 1px solid var(--line); color: var(--muted); border-radius: 6px; cursor: pointer; padding: 2px 8px; }

.filters { display: flex; gap: 10px; margin-bottom: 12px; align-items: center; flex-wrap: wrap; }
select { background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; font: inherit; }
.chronicle .day { font-family: var(--serif); color: var(--gold); font-size: 18px; margin: 18px 0 6px; border-bottom: 1px solid var(--line); }

.realms { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 16px; }
.realm { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; border-top: 3px solid var(--muted); }
.realm h2 { font-family: var(--serif); font-weight: normal; margin: 0 0 2px; }
.site { margin: 6px 0; }
.notice { background: var(--panel2); color: var(--ink); border-left: 3px solid var(--gold); padding: 8px 10px; border-radius: 4px; margin: 6px 0; font-family: var(--serif); transform: rotate(-.4deg); }
.agent-cmd, .reports pre { white-space: pre-wrap; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px; font: 13px/1.5 ui-monospace, monospace; }
.muted { color: var(--muted); }

.dialogue { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; margin: 8px 0; }
.dialogue .dh { color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.dialogue .line { padding: 2px 0; color: #d8cdb5; }
.dialogue .line b { color: var(--ink); font-weight: 600; }

.join { max-width: 640px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin-bottom: 16px; }
.join label { display: block; margin: 8px 0; color: var(--muted); }
.join label[hidden] { display: none; }
.join label.inline { display: inline-block; margin-right: 14px; color: var(--ink); }
.join input:not([type=checkbox]), .join textarea, .join select { display: block; width: 100%; margin-top: 3px; background: var(--panel2); color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; font: inherit; }
.join fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 10px 0; }
.join fieldset.plain { border: 0; margin: 0; padding: 0; }
.join legend { color: var(--gold); font-family: var(--serif); }
.join button { background: var(--panel2); color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: 6px 12px; font: inherit; cursor: pointer; margin: 6px 6px 6px 0; }
.join button[type=submit] { border-color: var(--gold); }
#join-result, #check-result { margin-top: 8px; }

.more { display: block; margin: 8px auto; background: none; border: 1px solid var(--line); color: var(--ink); border-radius: 6px; padding: 4px 12px; cursor: pointer; }
.more[hidden] { display: none; }
.ev .x { overflow-wrap: anywhere; }

.portrait { float: left; width: 44px; height: 44px; border-radius: 50%; object-fit: cover; margin: 0 10px 4px 0; border: 1px solid var(--line); }
.portrait.big { float: right; width: 160px; height: 160px; border-radius: 10px; margin: 0 0 10px 16px; }
.portrait.empty { display: grid; place-items: center; background: var(--panel2); color: var(--muted); font: 48px var(--serif); }
.mine-char { display: flex; padding: 10px 0; border-top: 1px solid var(--line); }
.mine-char .portrait.big { float: none; margin: 0 16px 0 0; }
.mine-char h4 { margin: 0; font-family: var(--serif); font-size: 17px; }
.mine-char .rise-line { margin: 6px 0 10px; }
.mine-char.dead .portrait { filter: grayscale(1); opacity: 0.7; }
.mine-char .died { color: var(--red); margin-top: 2px; }
.mine-deaths { border: 1px solid var(--red); border-radius: 6px; padding: 8px 12px; margin: 8px 0; color: var(--red); }
.join label.button input { display: none; }
.join label.button { display: inline-block; color: var(--ink); background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 6px 12px; cursor: pointer; margin: 6px 6px 6px 0; }
@media (max-width: 520px) { .mine-char { flex-direction: column; } .portrait.big { width: 120px; height: 120px; } }
.realm h3 { margin: 14px 0 6px; }
.members { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 4px; }
.member { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 3px; border-radius: 999px; background: var(--panel2); border: 1px solid var(--line); cursor: pointer; font-size: 13px; }
.member:hover { border-color: var(--gold); }
.member:not(:has(img)) { padding-left: 10px; }
.portrait.tiny { float: none; width: 22px; height: 22px; margin: 0; }
.realm .fold > div { display: flex; flex-wrap: wrap; gap: 2px; }

.card .whisper { margin-top: 6px; font-size: 13px; color: #c9b8ea; font-style: italic; }
.whisper-block { border-left: 2px solid #9b7fd6; padding: 4px 10px; margin: 8px 0; }
.answer { margin: 4px 0; color: #e6dcc4; font-style: normal; }
#my-voices .came { margin: 4px 0 0 10px; border-left: 2px solid #9b7fd6; padding-left: 8px; }

.wiki-page h3 { margin-top: 22px; }
.wiki-rule { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 2px 14px; margin: 6px 0; max-width: 900px; }
.wiki-rule summary { font-family: var(--serif); color: var(--gold); font-size: 16px; }
.wiki-rule p { line-height: 1.55; }
table.wiki { border-collapse: collapse; width: 100%; font-size: 13px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
table.wiki th { text-align: left; color: var(--gold); font-weight: normal; font-family: var(--serif); background: var(--panel2); padding: 6px 8px; }
table.wiki td { padding: 5px 8px; border-top: 1px solid #2e271e; vertical-align: top; }
#wiki-q { background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; font: inherit; width: min(420px, 100%); }
@media (max-width: 700px) { table.wiki { display: block; overflow-x: auto; } }
.epithet { font-style: italic; color: var(--muted); font-size: 13px; }
.flaw { color: #e0675a; font-size: 13px; }
.virtue { color: #6fc27a; font-size: 13px; }
.flaw .does, .virtue .does { color: var(--muted); }
h2 .epithet { font-size: 0.7em; }
.life { margin: 10px 0 4px; }
.life h3 { margin: 0 0 6px; }
.life .changes, .realm .changes { max-height: 300px; overflow-y: auto; scrollbar-color: var(--line) transparent; }
.realm ol.laws { margin: 4px 0 10px 20px; padding: 0; font-family: var(--serif); }

/* Item, building and creature cards that open over anything (info.js). */
a.ref { color: inherit; text-decoration: underline dotted var(--muted); text-underline-offset: 2px; cursor: pointer; }
a.ref:hover { color: var(--gold); text-decoration-color: var(--gold); }
.info-pop { position: fixed; z-index: 50; width: 360px; max-height: 70vh; overflow: auto; background: rgba(33,28,22,.98); border: 1px solid var(--gold); border-radius: 10px; padding: 10px 14px; font-size: 13px; line-height: 1.4; box-shadow: 0 8px 28px rgba(0,0,0,.55); }
.info-pop h4 { margin: 0 50px 2px 0; font-family: var(--serif); font-size: 17px; color: var(--gold); }
.info-pop h5 { margin: 10px 0 3px; font-size: 12px; color: var(--gold); text-transform: uppercase; letter-spacing: .04em; }
.info-pop p { margin: 6px 0; }
.info-pop ul.plain { margin: 2px 0; padding: 0; list-style: none; }
.info-pop ul.plain li { margin: 2px 0; }
.info-acts { position: sticky; top: 0; float: right; display: flex; gap: 4px; }
.info-acts button { background: var(--panel2); border: 1px solid var(--line); color: var(--ink); border-radius: 6px; padding: 1px 8px; cursor: pointer; }
@media (max-width: 700px) { .info-pop { left: 8px !important; right: 8px; top: auto !important; bottom: 8px; width: auto; max-height: 60%; } }
.info-who { display: flex; gap: 10px; align-items: center; margin-bottom: 4px; }
.info-who .face { width: 44px; height: 44px; flex: none; border-radius: 50%; border: 3px solid var(--line); object-fit: cover; display: grid; place-items: center; background: var(--panel2); font-size: 20px; }
.info-pop .why { font-style: italic; }
.info-pop ol.laws { margin: 2px 0; padding-left: 20px; }
.info-go { display: flex; gap: 6px; margin-top: 10px; }
.info-go button { background: var(--panel2); border: 1px solid var(--line); color: var(--ink); border-radius: 6px; padding: 3px 10px; cursor: pointer; font-size: 12px; }

/* The tavern: the players' room, a panel at the right over whatever tab is open. */
.talk-new { margin-left: 4px; background: var(--gold); color: var(--bg); border-radius: 8px; padding: 0 5px; font-size: 11px; }
.talk-new[hidden] { display: none; }

/* The players' chat: at the bottom of the map, right of the finder, and left of a card while one is open. */
.stage-card:not([hidden]) ~ .chat { right: 394px; }
.chat { position: absolute; z-index: 5; left: 264px; right: 12px; bottom: 34px; height: min(35vh, calc(100% - 110px)); display: flex; flex-direction: column; background: rgba(33,28,22,.9); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 6px 24px rgba(0,0,0,.45); font-size: 13px; }
.chat[hidden] { display: none; }
.chat-head { display: flex; gap: 6px; align-items: center; padding: 5px 8px; border-bottom: 1px solid var(--line); }
.chat-filters { flex: 1; display: flex; flex-wrap: wrap; gap: 4px; }
.chat-filters button { font-size: 12px; color: var(--muted); background: none; border: 1px solid var(--line); border-radius: 10px; padding: 1px 8px; cursor: pointer; }
.chat-filters button.on { color: var(--ink); background: var(--panel2); border-color: var(--gold); }
#chat-min { background: none; border: 0; color: var(--muted); font-size: 16px; cursor: pointer; }
/* Shut, only the line shows; open, it keeps one size and its stream scrolls. */
.chat.min { height: auto; }
.chat.min .chat-head, .chat.min .chat-log, .chat.min #ask-result { display: none; }
.chat.min .chat-form { border-top: 0; }
.chat-log { flex: 1; min-height: 0; overflow: auto; padding: 6px 10px; display: flex; flex-direction: column; gap: 6px; line-height: 1.4; }
.chat-log .line b { color: var(--ink); font-weight: 600; }
.chat-log .line .muted { font-size: 11px; }
.chat-log .line > div { white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-log .line.mine > b { color: var(--gold); }
.chat-log .line.logos { border-left: 2px solid var(--gold); padding-left: 8px; font-family: var(--serif); }
.chat-log .line.logos b { color: var(--gold); }
.chat-log .line.wait { color: var(--muted); font-style: italic; }
.chat-log .line.whisper { border-left: 2px solid #9b7fd6; padding-left: 8px; }
.chat-log .line.course { border-left: 2px solid var(--gold); padding-left: 8px; }
.chat-log .line a { color: inherit; text-decoration: underline dotted; cursor: pointer; }
.chat-log .came { font-style: italic; color: var(--muted); }
.chat-log .noted { font-size: 12px; color: var(--muted); border-left: 2px solid var(--gold); padding: 2px 0 2px 8px; margin-top: 4px; }
.chat-form { display: flex; gap: 6px; padding: 6px; border-top: 1px solid var(--line); }
.chat-form select, .chat-form input, .chat-form textarea { background: var(--bg); color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: 5px 7px; font: inherit; }
.chat-form select { flex: 0 1 190px; min-width: 70px; }
.chat-form input { flex: 0 1 120px; min-width: 60px; }
.chat-form input[hidden] { display: none; }
.chat-form textarea { flex: 1 1 0; min-width: 80px; resize: none; overflow: hidden; }
.chat-form textarea::placeholder { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-form button { flex: none; padding: 0 14px; border-radius: 6px; border: 1px solid var(--gold); background: var(--panel2); color: var(--gold); font: inherit; cursor: pointer; }
#ask-result { padding: 0 10px; font-size: 12px; }
#ask-result:not(:empty) { padding-bottom: 6px; }
@media (max-width: 900px) {
  .chat, .stage-card:not([hidden]) ~ .chat { left: 8px; right: 8px; bottom: 34px; }
  .chat:not([hidden]) ~ .stage-hud { bottom: 84px; }
  .chat:not(.min) { height: 35vh; }
}

/* The map's key, top left of the valley. */
.legend-open { position: absolute; left: 12px; top: 12px; z-index: 4; padding: 4px 10px; border-radius: 8px; border: 1px solid var(--line); background: rgba(33,28,22,.92); color: var(--ink); font-family: var(--serif); cursor: pointer; }
.legend { position: absolute; left: 12px; top: 44px; z-index: 4; width: 330px; max-height: calc(100% - 120px); overflow: auto; background: rgba(33,28,22,.96); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 13px; line-height: 1.35; }
.legend[hidden], .legend-open[hidden] { display: none; }
.legend b { display: block; margin: 6px 0 4px; color: var(--gold); font-family: var(--serif); }
.legend .grid { display: grid; grid-template-columns: 24px 1fr; gap: 3px 6px; }
.agent-cmd { word-break: break-all; }
.diplo-board, .realm.levers { grid-column: 1 / -1; }
table.diplo { border-collapse: collapse; margin: 8px 0; font-size: 13px; }
table.diplo th, table.diplo td { padding: 3px 8px; text-align: center; border-bottom: 1px solid var(--line, #3333); }
table.diplo tr th:first-child { text-align: left; }
.levers .stances { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 6px 0; }
.levers .motion-form { display: block; }
.motion-head { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.motion-what { margin: 6px 0; font-size: 13px; }
.motion-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; margin: 6px 0 8px; }
.motion-fields .field { display: flex; flex-direction: column; gap: 3px; font-size: 13px; }
.motion-fields .field[hidden] { display: none; }
.motion-fields .field input:not([type=checkbox]) { width: 100%; box-sizing: border-box; }
.motion-fields .field input[type=checkbox] { align-self: flex-start; }
.hint { cursor: pointer; color: var(--gold); text-decoration: none; }
.levers .course-form, .levers .levy-form { margin: 8px 0; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.levers .course-form textarea { width: 100%; }
.levers .levy-form input { width: 60px; }
.rate-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px; width: 100%; margin-top: 4px; align-items: start; }
.rate-card { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: 13px; }
.rate-card summary { cursor: pointer; }
.rate-card[open] { border-color: var(--gold); }
.rate-card p { margin: 6px 0 0; }
.levers input:not([type=checkbox]), .levers textarea, .levers button { background: var(--panel2); color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; font: inherit; }
.levers button { cursor: pointer; }
