/* The dark plum look is the standard one: everybody gets it, whatever their device is set to, so the game looks the
   same in every screenshot. The light one is a choice made in Settings (theme.js puts it on the page). */
:root {
  color-scheme: dark;
  --bg: #17101e;
  --panel: #221a2e;
  --ink: #ece6f6;
  --muted: #a299b3;
  --line: #3a3049;
  --accent: #d9ab56;
  --accent-ink: #1d1408;
  --player: #2c2340;
  --hp: #d9665d;
  --sp: #e58f4a;
  --mp: #5fb3e6;
  --warn: #e0a84d;
  --danger: #e0756c;
  --dice: #d9ab56;
  --gilt: #b89a66;
  --radius: 10px;
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f3f9;
  --panel: #ffffff;
  --ink: #1c1a22;
  --muted: #6a6577;
  --line: #dcd7e6;
  --accent: #4b3472;
  --accent-ink: #ffffff;
  --player: #ebe5f8;
  --hp: #b5443c;
  --sp: #c08a2b;
  --mp: #2f7fb5;
  --warn: #9a5a00;
  --danger: #a3352d;
  --dice: #9a6d14;
  --gilt: #7d6534;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h1 { font-size: 1.5rem; margin: 0 0 .25rem; color: var(--dice); }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; color: var(--dice); }
h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--gilt); margin: 1rem 0 .35rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.warning { color: var(--warn); }
[hidden] { display: none !important; }

button, input, textarea, select { font: inherit; color: inherit; }
input, textarea, select {
  width: 100%;
  padding: .6rem .7rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}
textarea { resize: none; }
input, select { accent-color: var(--accent); }
:focus-visible { outline: 2px solid var(--dice); outline-offset: 1px; }
label { display: block; margin-bottom: .8rem; font-size: .9rem; }
label > input, label > textarea, label > select { margin-top: .3rem; }
label.check { display: flex; align-items: center; gap: .45rem; }
label.check > input { width: auto; margin: 0; }
button { cursor: pointer; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); padding: .55rem .9rem; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 600; }
button.ghost { background: transparent; }
button:disabled { opacity: .5; cursor: default; }
a { color: var(--accent); }
.muted a { color: inherit; }
#notice li { margin-bottom: .4rem; }
button.link { border: 0; background: none; padding: 0; color: var(--muted); text-decoration: underline; font-size: .8rem; }

/* ---------- start screen ---------- */
.signin-buttons { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
#signin, #notice { max-width: 560px; margin: 0 auto; padding: 1.5rem 1rem 3rem; }
.start-head { margin-bottom: 1.25rem; }
/* The FateScape logo. Its own ground is the dark theme's, so there it has no visible edge. */
.brand-logo { display: block; width: min(100%, 22rem); height: auto; margin: 0 0 .5rem -1rem; border-radius: var(--radius); }
:root[data-theme="light"] .brand-logo { margin-left: 0; }
.brand-name { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.card { background: var(--panel); border: 1px solid color-mix(in srgb, var(--dice) 28%, var(--line)); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; }
.story-world { margin: 0 0 .2rem; text-transform: uppercase; letter-spacing: .06em; font-size: .75rem; color: var(--gilt); }
.story-about { margin: 0 0 .5rem; }
.story-card h2 { margin-bottom: .5rem; }
.story-about { margin-bottom: .6rem; }
.story-marks { margin: 0 0 .9rem; }
#story-companions:empty { display: none; }

/* ---------- the pages outside a chat ----------
   Three widths decide the layout (docs/Feature_Design/UI_LAYOUT.md): narrow under 720px, medium to 1099px, wide from
   1100px. The grids below fill by themselves; the widths decide where the links to the pages sit. */
.site-bar {
  position: sticky; top: 0; z-index: 3; display: flex; align-items: center; gap: 1.75rem; height: 4rem;
  padding: 0 max(1rem, calc((100% - 1200px) / 2 + 1rem));
  background: var(--bg); border-bottom: 1px solid color-mix(in srgb, var(--dice) 28%, var(--line));
}
.bar-home { flex: none; line-height: 0; }
.bar-logo { display: block; height: 2.75rem; width: auto; border-radius: 6px; }
.site-nav { display: flex; gap: 1.5rem; align-self: stretch; }
.site-nav a, .bar-account { display: flex; align-items: center; align-self: stretch; color: var(--muted); text-decoration: none; border-top: 2px solid transparent; border-bottom: 2px solid transparent; }
.site-nav a:hover, .bar-account:hover { color: var(--ink); }
.site-bar a[aria-current="page"] { color: var(--dice); font-weight: 600; border-bottom-color: var(--dice); }
.bar-credit { margin-left: auto; white-space: nowrap; }
.site-tabs { display: none; }
.site-body { max-width: 1200px; margin: 0 auto; padding: 1.75rem 1rem 3rem; }
/* The pages that are still one column of cards. */
.page-column { max-width: 560px; margin-left: auto; margin-right: auto; }
.row-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin: 0 0 .75rem; }
.row-head h2 { margin: 0; font-size: 1.25rem; }
.row-head a { color: var(--muted); }
a.card { display: block; color: inherit; text-decoration: none; }
a.card:hover { border-color: var(--dice); }

/* Home: the chats to continue, then the Fates. Each is a grid that makes as many columns as fit. */
#saved { margin-bottom: 2rem; }
.chat-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1.25rem; }
.chat-card { margin: 0; min-width: 0; }
.chat-card > div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-card .who { font-weight: 600; }
.fate-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1.25rem; margin-bottom: 1.5rem; }
a.story-card { display: flex; flex-direction: column; padding: 0; margin: 0; overflow: hidden; }
/* Covers are drawn upright, three wide to four tall, whatever the picture's own shape. */
.story-cover {
  position: relative; flex: none; overflow: hidden; aspect-ratio: 3 / 4; background: var(--player); color: var(--gilt);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .6rem;
  font-size: .75rem; letter-spacing: .14em; text-transform: uppercase; text-align: center;
}
.story-cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.story-cover .dice-icon { width: 2.5rem; height: 2.5rem; margin: 0; }
.story-text { flex: 1; display: flex; flex-direction: column; gap: .35rem; padding: .85rem 1rem 1rem; }
.story-text > * { margin: 0; }
.story-name { font-size: 1.05rem; line-height: 1.3; font-weight: 600; text-transform: none; letter-spacing: 0; color: var(--dice); }
/* The hook is short by rule (StoryInfo.HookLimit), so a card shows all of it and never cuts it. */
a.story-card .story-about { font-size: .9rem; }
/* Over the picture: the rules system on the left, the rating on the right. The same in both themes, since they sit on the picture. */
.story-badges { position: absolute; z-index: 1; inset: .5rem .5rem auto; display: flex; justify-content: space-between; align-items: flex-start; gap: .4rem; }
.badge { padding: .2rem .5rem; border-radius: 999px; font-size: .68rem; font-weight: 700; letter-spacing: .06em; line-height: 1.2; text-transform: uppercase;
  background: rgba(24, 18, 32, .85); color: #ece6f6; border: 1px solid rgba(217, 171, 86, .45); }
.badge:empty { visibility: hidden; }
.badge-sfw { color: #d9ab56; }
.badge-m17 { background: #b0492c; border-color: #b0492c; color: #fff; }
/* The last line of a card, kept at its foot however long the lines above are. */
.story-foot { margin-top: auto; padding-top: .35rem; display: flex; align-items: center; gap: .9rem; font-size: .8rem; color: var(--muted); }
.story-count { display: inline-flex; align-items: center; gap: .3rem; }
.story-count svg { width: 1em; height: 1em; }
.story-new { padding: .1rem .5rem; border: 1px solid var(--dice); border-radius: 999px; color: var(--dice); font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }

/* My chats: one row for each chat, in two columns where they fit. */
.chat-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 26rem), 1fr)); gap: 1rem; }
a.chat-item { display: flex; align-items: center; gap: 1rem; margin: 0; padding: .75rem 1rem .75rem .75rem; min-width: 0; }
.chat-item .story-cover { width: 3.75rem; border-radius: 8px; }
.chat-item .story-cover .dice-icon { width: 1.6rem; height: 1.6rem; }
.chat-item-text { flex: 1; min-width: 0; }
.chat-item-text > div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item-fate { font-weight: 600; color: var(--dice); }
.chat-item-side { flex: none; text-align: right; font-variant-numeric: tabular-nums; }

/* Personas: the list on the left, the one chosen on the right. */
.personas-layout { display: grid; grid-template-columns: 18rem minmax(0, 1fr); gap: 1.5rem; align-items: start; }
.personas-side { display: flex; flex-direction: column; gap: .6rem; }
.personas-list { display: flex; flex-direction: column; gap: .5rem; }
.personas-list:empty { display: none; }
.persona-item { display: flex; flex-direction: column; gap: .1rem; width: 100%; text-align: left; padding: .6rem .8rem; border-radius: var(--radius); }
.persona-item > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.persona-item-name { font-weight: 600; }
.persona-item[aria-current="true"], #persona-new[aria-current="true"] { background: var(--player); border-color: var(--accent); }
.personas-one { max-width: 40rem; }
.personas-back { display: none; margin: 0 0 .6rem; }
.personas-back button.link { font-size: inherit; }
/* On this page the list does the choosing, and the card says whose it is. */
#personas-slot #persona-pick, #personas-slot > .card > h2 { display: none; }
.persona-name { display: none; }
#personas-slot .persona-name { display: block; margin: 0 0 .5rem; font-size: 1.15rem; text-transform: none; letter-spacing: 0; color: var(--dice); }
#personas-slot #persona-about { font-size: 1rem; white-space: pre-wrap; }
.card > .last, .card .last { margin-bottom: 0; }
@media (max-width: 719px) {
  .chat-item-side { display: none; }
  /* The list and the one chosen take turns. */
  .personas-layout { grid-template-columns: minmax(0, 1fr); }
  .personas-layout[data-view="list"] .personas-one, .personas-layout[data-view="one"] .personas-side { display: none; }
  .personas-back { display: block; }
}

/* A Fate's page: the Fate on the left, and on the right the panel where it is begun, which stays in view. */
.story-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(20rem, 26rem); gap: 2rem; align-items: start; }
.fate-about { display: grid; grid-template-columns: 14rem minmax(0, 1fr); grid-template-areas: "cover head" "cover text"; grid-template-rows: auto 1fr; gap: .75rem 1.5rem; margin: 0; }
.fate-about .story-cover { grid-area: cover; border-radius: 8px; }
.fate-head { grid-area: head; }
.fate-head h2 { font-size: 1.6rem; line-height: 1.25; margin: 0 0 .4rem; }
.fate-head .story-marks { margin: 0; }
/* The page says what the card says: the badges in a line, the hook under them, then how much it has been played. */
.fate-badges { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin: 0 0 .6rem; }
.fate-hook { margin: 0 0 .5rem; font-size: 1.1rem; line-height: 1.45; color: var(--gilt); }
.fate-head .story-foot { margin: 0; }
/* The creator's capsule: a round mark where their picture will go, then who they are. */
.fate-creator { display: inline-flex; align-items: center; gap: .6rem; margin-top: .8rem; padding: .35rem .9rem .35rem .4rem; border: 1px solid var(--line); border-radius: 999px; background: var(--player); }
.fate-creator-mark { width: 2rem; height: 2rem; border-radius: 50%; display: grid; place-items: center; background: var(--dice); color: var(--accent-ink); font-weight: 700; }
.fate-creator-text { display: flex; flex-direction: column; line-height: 1.2; }
.fate-creator-name { font-weight: 600; }
/* Its facts, under the description: a name on the left and what it is on the right. */
.fate-facts-box { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--line); font-size: .9rem; max-width: 26rem; }
.fate-facts { margin: 0 0 .6rem; }
.fate-facts > div { display: flex; justify-content: space-between; gap: 1rem; padding: .2rem 0; }
.fate-facts dt { color: var(--muted); }
.fate-facts dd { margin: 0; text-align: right; }
.fate-facts .fate-facts-total { font-weight: 600; border-top: 1px solid var(--line); margin-top: .2rem; padding-top: .4rem; }
.fate-facts .fate-facts-total dt { color: inherit; }
.fate-facts-box p { margin: 0; line-height: 1.45; }
.fate-text > p:first-child { margin: 0; }
.fate-text { grid-area: text; margin: 0; font-size: 1.05rem; line-height: 1.6; max-width: 62ch; }
.begin-panel { position: sticky; top: 5rem; max-height: calc(100dvh - 11rem); overflow-y: auto; margin: 0; display: flex; flex-direction: column; gap: 1rem; border-color: color-mix(in srgb, var(--dice) 45%, var(--line)); }
/* The persona card inside the panel is part of it, not a card of its own. */
#story-persona-slot > .card { border: 0; padding: 0; margin: 0; background: none; }
#story-persona-slot #persona-about:not(.open) { display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
#personas-slot .about-more { display: none; }
.begin-panel .companions { margin: 0; }
/* The button stays at the bottom of the panel however long the panel's contents are. */
.begin-bar { position: sticky; bottom: 0; margin-bottom: -1rem; padding: .75rem 0 1rem; background: var(--panel); }
.begin-bar button { width: 100%; padding: .8rem; }
/* Settings that fold away, each one line with a ? that opens what it means. */
.more-options { border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem .8rem; }
.more-options > summary { cursor: pointer; }
.more-title { font-weight: 600; color: var(--dice); }
.option { margin-top: .85rem; }
.option-head { display: flex; align-items: center; justify-content: space-between; gap: .6rem; margin-bottom: .3rem; }
.option-head label { margin: 0; }
button.help { flex: none; width: 1.6rem; height: 1.6rem; padding: 0; border-radius: 999px; background: transparent; color: var(--muted); font-size: .85rem; line-height: 1; }
button.help[aria-expanded="true"] { background: var(--player); border-color: var(--accent); color: var(--dice); }
.help-text { margin: .4rem 0 0; padding: .5rem .65rem; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; }
@media (max-width: 1099px) {
  .story-layout { gap: 1.25rem; }
  .fate-about { grid-template-columns: 9rem minmax(0, 1fr); gap: .6rem 1rem; }
  .fate-head h2 { font-size: 1.3rem; }
}
/* Narrow: one column. The button that begins the Fate takes the place of the tabs at the bottom edge. */
@media (max-width: 719px) {
  .story-layout { grid-template-columns: minmax(0, 1fr); gap: 1rem; }
  .fate-about { grid-template-columns: 6.5rem minmax(0, 1fr); grid-template-areas: "cover head" "text text"; }
  .fate-text { font-size: 1rem; }
  .fate-hook { font-size: 1rem; }
  .begin-panel { position: static; max-height: none; overflow: visible; }
  #start[data-page="story"] .site-tabs { display: none; }
  .begin-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 3; margin: 0; padding: .6rem .9rem calc(.6rem + env(safe-area-inset-bottom)); background: var(--panel); border-top: 1px solid color-mix(in srgb, var(--dice) 28%, var(--line)); }
  button.help { width: 2rem; height: 2rem; }
}

/* Narrow: the bar keeps the logo and the dice, the pages move to tabs at the bottom, and the cards on Home sit side by
   side in rows that scroll sideways, with the edge of the next card showing. */
@media (max-width: 719px) {
  .site-bar { height: 3.25rem; padding: 0 .9rem; }
  .bar-logo { height: 2.25rem; }
  .site-nav, .bar-account { display: none; }
  .site-body { padding: 1.1rem .9rem calc(5.5rem + env(safe-area-inset-bottom)); }
  .site-tabs {
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); position: fixed; left: 0; right: 0; bottom: 0; z-index: 3;
    padding-bottom: env(safe-area-inset-bottom); background: var(--panel); border-top: 1px solid color-mix(in srgb, var(--dice) 28%, var(--line));
  }
  .site-tabs a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .15rem; min-height: 4rem; font-size: .75rem; color: var(--muted); text-decoration: none; }
  .site-tabs a[aria-current="page"] { color: var(--dice); font-weight: 600; }
  .site-tabs svg { width: 22px; height: 22px; }
  /* A row scrolled sideways: the chats to continue, and later any picked row of Fates, such as the featured ones. */
  .side-row { display: flex; gap: .6rem; overflow-x: auto; margin-right: -.9rem; padding-right: .9rem; scroll-snap-type: x proximity; scrollbar-width: none; }
  .side-row > * { flex: none; scroll-snap-align: start; }
  .chat-card { width: 236px; }
  .side-row a.story-card { width: 168px; }
  /* The whole list of Fates goes down the page, two to a line. */
  .fate-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
  a.story-card .story-world { display: none; }
  .story-text { padding: .6rem .75rem .75rem; }
  .story-name { font-size: .95rem; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  a.story-card .story-about { font-size: .8rem; }
  .story-text .story-foot { gap: .7rem; font-size: .75rem; }
}

.meters { display: flex; flex-wrap: wrap; gap: .3rem; margin: .4rem 0 .2rem; }

/* ---------- the map: a minimap in the bar, and the whole map in a panel beside the story ---------- */
.minimap { padding: 3px; line-height: 0; flex: none; }
.mini-grid { display: grid; grid-template-columns: repeat(5, 9px); grid-auto-rows: 9px; gap: 1px; }
.mini-sq { background: var(--line); opacity: .5; border-radius: 1px; }
.mini-sq.been, .mini-sq.here { opacity: 1; }
.mini-sq.here { outline: 2px solid var(--accent); outline-offset: -1px; position: relative; z-index: 1; }
.mini-sq.off { background: transparent; }
/* a way that leads off this map, at the edge of the minimap on its side */
.mini-sq.far { opacity: 1; background: var(--accent) !important; border-radius: 50%; transform: scale(.6); }
/* a tile of a built map that nobody has been to yet, and one that has not been laid */
.map-sq.stub { outline: 1px dashed var(--muted); outline-offset: -1px; }
.map-sq.unlaid { background: transparent; cursor: default; }
.map-sq.strip { opacity: .4 !important; cursor: default; border-radius: 0; }
#map-panel { width: 21rem; }
#map-panel .map-sq { cursor: pointer; font-size: .9rem; }
.map-sq.picked { box-shadow: inset 0 0 0 2px var(--ink); }
/* the tile that leads in to where the party is, on a map further out */
.map-sq.holds { opacity: 1; outline: 2px dashed var(--accent); outline-offset: 0; }
.map-path { margin-bottom: .6rem; }
.map-path button.link { font-size: inherit; }
.map-info { border-top: 1px solid var(--line); padding-top: .5rem; margin-top: .5rem; min-height: 3.4rem; }
.map-info button.link { font-size: inherit; color: var(--accent); }
.map-key { margin-top: .5rem; }
.map-grid { display: grid; gap: 2px; margin: .5rem 0 .35rem; }
.map-label { font-size: .65rem; color: var(--muted); text-align: center; line-height: 1.1rem; }
.map-sq { aspect-ratio: 1; border-radius: 2px; background: var(--line); opacity: .55; font-size: .7rem; line-height: 1; display: flex; align-items: center; justify-content: center; color: #fff; }
.map-sq.been { opacity: 1; }
.map-sq.here { opacity: 1; outline: 2px solid var(--accent); outline-offset: 0; }
.saved-list { list-style: none; margin: 0; padding: 0; }
.saved-list li + li { border-top: 1px solid var(--line); }
.saved-list a { display: block; color: inherit; text-decoration: none; padding: .7rem 0; }
.saved-list .who { font-weight: 600; }

/* ---------- game screen ---------- */
#game { display: flex; flex-direction: column; height: 100dvh; }
.bar {
  display: flex; align-items: center; gap: .5rem;
  padding: .5rem .75rem; border-bottom: 1px solid color-mix(in srgb, var(--dice) 28%, var(--line)); background: var(--panel);
}
.bar-mid { flex: 1; min-width: 0; }
.bar-place { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.layout { flex: 1; min-height: 0; display: flex; position: relative; overflow: hidden; }
.log { flex: 1; min-width: 0; overflow-y: auto; padding: 1rem; }
.log-inner, .log > * { max-width: 46rem; margin-left: auto; margin-right: auto; }

.turn { margin-bottom: 1.4rem; }
.said { background: var(--player); border-radius: var(--radius); padding: .55rem .8rem; margin: 0 0 .6rem auto; width: fit-content; max-width: 85%; }
.said-actions { display: flex; justify-content: flex-end; gap: .9rem; margin: -.35rem 0 .6rem; }
.said-edit { margin: 0 0 .6rem auto; max-width: 85%; }
.said-edit-buttons { display: flex; justify-content: flex-end; gap: .5rem; margin-top: .4rem; }
.said-edit-buttons button { font-size: .85rem; padding: .4rem .7rem; }
.prose p { margin: 0 0 .8rem; }
.prose { font-family: Georgia, "Iowan Old Style", "Times New Roman", serif; font-size: 1.06rem; line-height: 1.65; }
.prose.opening { color: var(--ink); }

/* ---------- formatted text (format.js) ----------
   What Markdown and the HTML a message may hold look like, in the narrator's text, the player's and the summaries.
   A message clips what it holds, so nothing typed into one can draw over the page around it. */
.fmt { overflow: hidden; overflow-wrap: anywhere; }
.fmt > :first-child { margin-top: 0; }
.fmt > :last-child { margin-bottom: 0; }
.fmt p { margin: 0 0 .8rem; }
.said.fmt p { margin: 0 0 .5rem; }
/* Spoken words: what stands between quotation marks. */
.spoken { color: var(--dice); }
.fmt h1, .fmt h2, .fmt h3, .fmt h4, .fmt h5, .fmt h6 { margin: 1.1rem 0 .45rem; line-height: 1.3; font-weight: 700; text-transform: none; letter-spacing: 0; color: var(--dice); }
.fmt h1 { font-size: 1.35em; } .fmt h2 { font-size: 1.2em; } .fmt h3 { font-size: 1.1em; }
.fmt h4, .fmt h5, .fmt h6 { font-size: 1em; }
.fmt ul, .fmt ol { margin: 0 0 .8rem; padding-left: 1.4rem; }
.fmt li { margin-bottom: .25rem; }
.fmt blockquote { margin: 0 0 .8rem; padding: .15rem .9rem; border-left: 3px solid var(--line); color: var(--muted); }
.fmt hr { border: 0; border-top: 1px solid var(--line); margin: 1rem 0; }
.fmt code { font-family: ui-monospace, Consolas, monospace; font-size: .9em; padding: .05rem .3rem; border-radius: 4px; background: var(--panel); }
.fmt pre { margin: 0 0 .8rem; padding: .6rem .8rem; border-radius: 8px; background: var(--panel); overflow-x: auto; }
.fmt pre code { padding: 0; background: none; }
.fmt table { border-collapse: collapse; margin: 0 0 .8rem; font-size: .92em; display: block; max-width: 100%; overflow-x: auto; }
.fmt th, .fmt td { border: 1px solid var(--line); padding: .3rem .6rem; text-align: left; }
.fmt th { color: var(--gilt); }
.fmt details { margin: 0 0 .8rem; }
.fmt summary { cursor: pointer; color: var(--gilt); }
.fmt img { max-width: 100%; height: auto; border-radius: 8px; }
.fmt div, .fmt span, .fmt center { max-width: 100%; }
.notice { border-left: 3px solid var(--warn); padding: .3rem .7rem; color: var(--muted); font-style: italic; }
.aside { border-left: 3px solid var(--line); padding: .3rem .7rem; color: var(--muted); white-space: pre-wrap; }
.error { border-left: 3px solid var(--danger); padding: .3rem .7rem; color: var(--danger); }
.status { color: var(--muted); font-size: .85rem; font-style: italic; }
.dice { margin: .2rem 0 .6rem; padding: .45rem .7rem; border: 1px dashed var(--line); border-radius: 8px; font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.dice div + div { margin-top: .15rem; }
.meta { display: flex; flex-wrap: wrap; gap: .25rem .9rem; align-items: center; font-size: .8rem; color: var(--muted); }
.meta .flagged { color: var(--danger); }
.earlier-flag { font-size: .8rem; color: var(--muted); font-style: italic; margin-top: .2rem; }
.note { font-size: .8rem; color: var(--warn); margin-top: .2rem; }

.bloodline { border: 1px solid var(--accent); border-radius: var(--radius); padding: .8rem 1rem; margin: .4rem 0 1rem; font-size: .95rem; }
.bloodline p { margin: .45rem 0 0; }
.bl-title { text-align: center; font-size: .75rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); }
.bl-name { text-align: center; font-weight: 600; margin-top: .15rem; }
.bl-lore { font-style: italic; color: var(--muted); margin-top: .4rem; }

/* ---------- sheet ---------- */
.sheet {
  width: 19rem; flex: none; overflow-y: auto; padding: .9rem; border-left: 1px solid var(--line); background: var(--panel);
  display: flex; flex-direction: column; font-size: .9rem;
}
#sheet-body { flex: 1; }
/* the settings panel: narrower than the sheet, as it holds little */
#settings { width: 16rem; }
#settings > h3:first-child { margin-top: 0; }
#cost-total > div + div { margin-top: .15rem; }
.who-name { font-weight: 600; }
.who-sub { color: var(--muted); font-size: .8rem; }
.bar-row { display: flex; align-items: center; gap: .4rem; margin-top: .25rem; font-size: .75rem; font-variant-numeric: tabular-nums; }
.bar-row span:first-child { width: 1.6rem; color: var(--muted); }
.bar-row span:last-child { width: 3.6rem; text-align: right; color: var(--muted); }
.meter { flex: 1; height: 7px; border-radius: 4px; background: var(--line); overflow: hidden; }
.meter i { display: block; height: 100%; }
.meter .hp { background: var(--hp); } .meter .sp { background: var(--sp); } .meter .mp { background: var(--mp); }
.stats { display: grid; grid-template-columns: repeat(7, 1fr); gap: .2rem; text-align: center; font-variant-numeric: tabular-nums; }
.stats b { display: block; font-size: .65rem; color: var(--muted); font-weight: 600; }

/* the persona's own attributes and looks */
.stat-inputs { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .3rem; margin-bottom: .4rem; }
.stat-inputs label { margin: 0; font-size: .7rem; text-align: center; color: var(--muted); }
.stat-inputs input { width: 100%; text-align: center; padding: .3rem .1rem; }
.look-inputs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 .6rem; }
.look-inputs label { margin-bottom: .4rem; font-size: .8rem; }

/* the classes offered at the awakening */
.class-choice { border-left: 3px solid var(--accent); padding-left: .6rem; margin: .5rem 0; }
.class-choice button { display: block; width: 100%; text-align: left; margin-top: .4rem; }
.class-choice button .muted { display: block; font-size: .8rem; margin-top: .15rem; }
.person { padding: .45rem 0; }
.person + .person { border-top: 1px solid var(--line); }
.hostile .who-name { color: var(--danger); }
.tag { display: inline-block; font-size: .7rem; padding: 0 .4rem; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); margin: .15rem .2rem 0 0; }
.sheet ul { margin: 0; padding-left: 1.1rem; }
.sheet details summary { cursor: pointer; }
.ability { margin-bottom: .4rem; }

/* parts of the sheet that fold away under a heading */
.sheet-section { margin: .9rem 0 .2rem; }
.sheet-section > summary { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 .5rem; list-style: none; padding: .2rem 0; }
.sheet-section > summary::-webkit-details-marker { display: none; }
.sheet-section > summary::before { content: "▶"; color: var(--gilt); font-size: .6rem; width: .7rem; flex: none; transition: transform .12s ease; }
.sheet-section[open] > summary::before { transform: rotate(90deg); }
.sheet-section-title { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--gilt); font-weight: 700; white-space: nowrap; }
.sheet-section-note { margin-left: auto; font-size: .75rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.sheet-section > summary:hover .sheet-section-title { color: var(--ink); }
.sheet-section > :not(summary) { margin-left: 1.2rem; }
.secondary-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: .2rem; text-align: center; font-variant-numeric: tabular-nums; margin: .35rem 0 .3rem; }
.secondary-grid b { display: block; font-size: .65rem; color: var(--muted); font-weight: 600; }
.secondary-sub { font-size: .75rem; color: var(--muted); font-weight: 600; margin: .7rem 0 .2rem; }
.senses-table { display: grid; grid-template-columns: 1fr auto auto auto; gap: .15rem .9rem; font-size: .85rem; font-variant-numeric: tabular-nums; margin-bottom: .3rem; }
.senses-table > span:not(.senses-name):not(.senses-head) { text-align: right; }
.senses-head { font-size: .65rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--line); padding-bottom: .1rem; }
.senses-head:not(:first-child) { text-align: right; }
.senses-name { text-transform: capitalize; }
.looks-list { display: grid; grid-template-columns: auto 1fr; gap: .25rem .7rem; font-size: .85rem; margin: .3rem 0 .3rem; }
.looks-label { color: var(--muted); font-size: .75rem; padding-top: .1rem; }
.looks-edit label { margin-bottom: .1rem; }
.looks-edit label > input, .looks-edit label > textarea { margin-top: .15rem; padding: .35rem .5rem; font-size: .85rem; }
.ability .cost { color: var(--muted); font-size: .8rem; }

/* a character's description, and the buttons under it */
.about { white-space: pre-wrap; }
.about p { margin: .3rem 0 0; }
.about.short p { display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.person-actions { display: flex; gap: .9rem; margin-top: .25rem; }
.who-edit { max-width: none; margin: .4rem 0 0; }
.who-edit > * + * { margin-top: .4rem; }
.who-edit label { margin-bottom: 0; }

/* someone else's whole sheet, over the page */
.full-sheet { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--ink); padding: 0; width: min(34rem, calc(100vw - 2rem)); max-height: 85dvh; font-size: .9rem; }
.full-sheet::backdrop { background: rgba(0, 0, 0, .45); }
.full-sheet-body { padding: 1rem; }
.full-sheet-close { float: right; font-size: .85rem; padding: .3rem .6rem; margin-left: .5rem; }
.full-sheet h3 { margin: 1rem 0 .35rem; }
.full-sheet p { margin: 0 0 .35rem; }
.full-sheet ul { margin: 0; padding-left: 1.1rem; }
.full-sheet details summary { cursor: pointer; }

/* ability points and free abilities */
.progress { display: flex; flex-direction: column; gap: .4rem; margin: .5rem 0; }
.progress:empty { display: none; }
.progress button { font-size: .85rem; padding: .4rem .6rem; text-align: left; }
.grant { border-left: 3px solid var(--accent); padding-left: .6rem; }
.learn { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; margin-top: .25rem; }
.learn select, .learn input[type=text] { font-size: .85rem; padding: .3rem .4rem; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); min-width: 0; }
.learn select { width: auto; flex: 0 1 auto; }
.learn input[type=text] { flex: 1 1 9rem; width: auto; }
.learn label { display: inline-flex; align-items: center; gap: .3rem; white-space: nowrap; }
.learn input[type=checkbox] { width: auto; margin: 0; }

/* ---------- input ---------- */
.say { display: flex; gap: .5rem; padding: .6rem .75rem calc(.6rem + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--panel); }
.say textarea { flex: 1; max-height: 9rem; }

/* ---------- the sheet button ---------- */
.panel-toggle[aria-pressed="true"] { background: var(--player); border-color: var(--accent); }
.side-panel.collapsed { display: none; }
.panel-toggle svg { display: none; width: 20px; height: 20px; }

/* ---------- the panels beside the story ----------
   chat.js decides which panels are shown (free, side or over: see PANELS there). This lays them out. Beside the story
   they sit in a row that scrolls sideways if they need more room than is left; the story never goes under 30rem. */
.panels { display: flex; flex: 0 1 auto; min-width: 0; overflow-x: auto; }
.panels > .side-panel { height: 100%; }
.dock-tabs { display: none; }
@media (min-width: 720px) {
  .log { flex: 1 0 30rem; }
}

/* ---------- narrow: no panel fits beside the story ----------
   The panels share one dock over the story, at full width, with its tabs along the top. The buttons in the bar become
   drawings, so the name of the place keeps its room. */
@media (max-width: 719px) {
  .bar { gap: .3rem; padding: .4rem .5rem; }
  .bar .panel-toggle { display: flex; align-items: center; justify-content: center; min-width: 2.75rem; min-height: 2.75rem; padding: 0 .4rem; }
  .panel-toggle svg { display: block; }
  /* The word stays for screen readers. */
  .panel-toggle span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .dock-tabs:not([hidden]) { display: flex; position: absolute; inset: 0 0 auto 0; height: 2.9rem; z-index: 3; background: var(--panel); border-bottom: 1px solid var(--line); }
  .dock-tabs button { flex: 1; min-width: 0; padding: 0 .3rem; border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: transparent; color: var(--muted); font-size: .9rem; }
  .dock-tabs button[aria-selected="true"] { color: var(--dice); font-weight: 600; border-bottom-color: var(--dice); }
  .dock-tabs .dock-close { flex: none; padding: 0 .8rem; color: var(--ink); border-left: 1px solid var(--line); }
  .panels { display: block; overflow: visible; }
  /* #game is named so this outweighs the widths the panels are given one by one. */
  #game .panels > .side-panel { position: absolute; inset: 2.9rem 0 0 0; width: auto; height: auto; z-index: 2; border-left: 0; }
}

/* ---------- short: a phone on its side, or a window squashed flat ----------
   The bar and the message box give their height to the story. */
@media (max-height: 519px) {
  .bar { padding: .15rem .5rem; }
  .bar-mid { display: flex; align-items: baseline; gap: .5rem; white-space: nowrap; overflow: hidden; }
  .bar .panel-toggle, .bar #back { padding-top: .3rem; padding-bottom: .3rem; }
  .log { padding: .6rem .9rem; }
  .say { padding: .3rem .5rem calc(.3rem + env(safe-area-inset-bottom)); }
  .say textarea { max-height: 4.5rem; padding-top: .45rem; padding-bottom: .45rem; }
  .sheet { padding: .6rem .75rem; }
}

/* Cards kept back until the person has picked a username. */
.held { display: none; }

/* Gear on the sheet: one row per slot, then what is carried. */
.gear-slots { display: grid; gap: .15rem; margin: .3rem 0 .6rem; }
.gear-slot { display: flex; align-items: center; gap: .5rem; font-size: .85rem; }
.gear-slot.empty { color: var(--muted); }
.gear-slot-name { min-width: 6.5rem; color: var(--muted); font-size: .75rem; }
.gear-items li { margin-bottom: .35rem; }
button.small-btn { font-size: .75rem; padding: .15rem .5rem; margin-left: .4rem; }

/* The battlefield: terrain under, people on top. */
.bf-sq { aspect-ratio: 1; border-radius: 2px; background: var(--line); font-size: .65rem; font-weight: 700; display: flex; align-items: center; justify-content: center; color: #fff; }
.bf-sq.cover { background: #4a4135; }
.bf-sq.difficult { background: repeating-linear-gradient(45deg, var(--line), var(--line) 3px, #6b5d48 3px, #6b5d48 5px); }
.bf-sq.water { background: #2f5d7c; }
.bf-sq.conceal { background: #3f5a35; }
.bf-sq.player { background: #3a6fb0; outline: 2px solid var(--accent); }
.bf-sq.ally { background: #3a6fb0; }
.bf-sq.enemy { background: #a33b3b; }
.bf-sq.civilian { background: #7a7a7a; }

/* The currency: its icon sits on the text line, in the text's own colour. */
.dice-amount { white-space: nowrap; }
.dice-icon { width: 1.15em; height: 1.15em; vertical-align: -0.22em; margin-right: .3em; }

/* The People panel: everyone met, where they are and how they stand toward the player. */
.people-row { padding: .35rem 0; border-top: 1px solid var(--line, rgba(128, 128, 128, .25)); }
.people-row:first-of-type { border-top: 0; }
.people-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 .5rem; }
.people-name { font-weight: 600; }
.people-track { margin: 0 0 0 auto; display: inline-flex; align-items: center; gap: .25rem; }
.people-track input { width: auto; margin: 0; }
.people-tie { font-style: italic; }
.people-changes > summary { cursor: pointer; }
.people-changes > div { margin-left: .9rem; }

/* Choosing who comes along, on a story's card. */
.companions { margin: 0 0 .9rem; padding: .6rem .7rem; border: 1px solid var(--line); border-radius: var(--radius); }
.companions-title { margin: 0 0 .4rem; font-weight: 600; color: var(--dice); }
.companions-note { margin: .4rem 0 0; }
.companion-row { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .6rem; padding: .25rem 0; margin: 0; }
.companion-who { display: flex; flex-direction: column; flex: 1 1 12rem; min-width: 0; }
.companion-name { font-weight: 600; }
.companion-row input[type="checkbox"] { flex: none; width: auto; margin: 0; }
.companion-relation { flex: 0 1 auto; width: auto; max-width: 100%; }
.companion-relation-fixed { padding: 0 .3rem; text-transform: capitalize; }
/* Who the player brings of their own: the choice of persona takes the room the name takes in the rows above. */
.bring-who { flex: 1 1 12rem; width: auto; min-width: 0; }
.companions + .companions { margin-top: .9rem; }

/* The Summary panel: the chat's chapters and volumes, and how they are written. */
#summary-panel { width: 22rem; }
.sum-head { display: flex; gap: .75rem; align-items: flex-start; }
.sum-head h3 { margin-top: 0; }
.sum-tokens { display: flex; flex-direction: column; align-items: flex-end; flex: none; line-height: 1.25; font-variant-numeric: tabular-nums; }
.sum-tokens b { font-size: 1.25rem; }
.sum-saved { color: var(--dice); }
.sum-stats { display: grid; grid-template-columns: repeat(3, 1fr); text-align: center; margin: .8rem 0; padding: .5rem 0; background: var(--bg); border-radius: var(--radius); }
.sum-stats > div + div { border-left: 1px solid var(--line); }
.sum-stats b { display: block; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.sum-auto { margin-bottom: .2rem; font-weight: 600; }
.sum-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: .3rem; margin: .9rem 0 .7rem; padding: .25rem; background: var(--bg); border-radius: var(--radius); }
.sum-tabs button { border-color: transparent; background: transparent; padding: .4rem; }
.sum-levels { display: grid; grid-template-columns: repeat(3, 1fr); gap: .35rem; margin-bottom: .35rem; }
.sum-levels button { padding: .4rem .2rem; line-height: 1.3; }
.sum-levels button b, .sum-levels button span { display: block; }
.sum-tabs button[aria-pressed="true"], .sum-levels button[aria-pressed="true"] { background: var(--player); border-color: var(--accent); }
.sum-go { width: 100%; margin-top: .8rem; padding: .7rem; }
.sum-hint { text-align: center; margin: .35rem 0 .2rem; }
.sum-list { margin-top: .8rem; display: flex; flex-direction: column; gap: .4rem; }
.sum-item { border: 1px solid var(--line); border-radius: var(--radius); padding: .5rem .65rem; background: var(--bg); }
.sum-item.volume { border-color: color-mix(in srgb, var(--dice) 45%, var(--line)); }
.sum-item > summary { display: flex; align-items: center; gap: .6rem; list-style: none; }
.sum-item > summary::-webkit-details-marker { display: none; }
.sum-item > summary::after { content: "▶"; color: var(--gilt); font-size: .6rem; margin-left: auto; transition: transform .12s ease; }
.sum-item[open] > summary::after { transform: rotate(90deg); }
.sum-badge { flex: none; min-width: 1.9rem; height: 1.9rem; padding: 0 .45rem; border-radius: 999px; background: var(--player); display: inline-flex; align-items: center; justify-content: center; font-size: .75rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.sum-item.volume > summary .sum-badge { background: var(--accent); color: var(--accent-ink); }
.sum-item.volume > summary .sum-title { color: var(--dice); }
.sum-names { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.sum-title { font-weight: 600; }
.sum-text { margin: .5rem 0 .35rem; overflow-wrap: anywhere; }
.sum-text p { margin: 0 0 .5rem; }
.sum-text h4 { margin: .9rem 0 .35rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--gilt); }
.sum-text h5 { margin: .6rem 0 .2rem; font-size: .9rem; color: var(--dice); }
.sum-text ul { margin: 0 0 .5rem; padding-left: 1.1rem; }
.sum-text li { margin-bottom: .25rem; }
.sum-inside { margin-top: .6rem; display: flex; flex-direction: column; gap: .35rem; }
.sum-inside .sum-item { background: var(--panel); }
.sum-own { border: 1px dashed var(--line); border-radius: var(--radius); padding: .5rem; margin-top: .4rem; display: flex; flex-direction: column; gap: .4rem; }
.sum-own-button { width: 100%; margin-top: .4rem; text-align: left; border-style: dashed; background: transparent; }
.sum-own-button b, .sum-own-button span { display: block; }
