@font-face { font-family: "IBM Plex Sans"; font-weight: 400; font-display: swap; src: url("/fonts/ibm-plex-sans-400.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 500; font-display: swap; src: url("/fonts/ibm-plex-sans-500.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 600; font-display: swap; src: url("/fonts/ibm-plex-sans-600.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 500; font-display: swap; src: url("/fonts/ibm-plex-mono-500.woff2") format("woff2"); }

:root {
  --bg: #f3ecdd;          /* parchment */
  --surface: #fbf7ee;
  --ink: #241d14;
  --muted: #74685a;
  --rule: #dccfb6;
  --accent: #8a3b12;      /* ember */
  --accent-ink: #fff;
  --accent-text: #8a3b12;
  --chip: #e9dfca;
  --good: #3c7a1e;
  --bad: #b3261e;
  --hp: #b3261e;
  --shadow: 0 1px 2px rgb(60 40 10 / 0.08), 0 8px 24px rgb(60 40 10 / 0.08);
  --sans: "IBM Plex Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --serif: "Iowan Old Style", "Charter", "Bitstream Charter", "Sitka Text", Cambria, Georgia, serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14110d; --surface: #1d1914; --ink: #ece4d4; --muted: #a29684; --rule: #362f25;
    --accent: #a8501e; --accent-text: #e59a63; --chip: #2b251d; --good: #7cc25a; --bad: #ef6b5f; --hp: #e0483c;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 8px 24px rgb(0 0 0 / 0.3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14110d; --surface: #1d1914; --ink: #ece4d4; --muted: #a29684; --rule: #362f25;
  --accent: #a8501e; --accent-text: #e59a63; --chip: #2b251d; --good: #7cc25a; --bad: #ef6b5f; --hp: #e0483c;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 8px 24px rgb(0 0 0 / 0.3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 16px/1.5 var(--sans); min-height: 100vh; display: flex; flex-direction: column; }
main { flex: 1; }
a { color: var(--accent-text); }
h1, h2, h3 { line-height: 1.2; }
.wrap { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 16px; } /* width: in the body's column, auto margins would shrink it */
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.error { color: var(--bad); }
.loading { color: var(--muted); padding: 48px 0; }
[hidden] { display: none !important; }

/* header */
.site-head { border-bottom: 1px solid var(--rule); }
.site-head .wrap { display: flex; align-items: center; gap: 18px; min-height: 56px; }
.brand { font-weight: 600; font-size: 1.1rem; color: var(--ink); text-decoration: none; }
.brand span { color: var(--muted); font-weight: 400; }
.sites { display: flex; gap: 12px; font-size: 0.85rem; }
.sites a { color: var(--muted); text-decoration: none; }
.sites a:hover { color: var(--ink); }
.account { margin-left: auto; display: flex; align-items: center; gap: 12px; font-size: 0.9rem; }
.account .me { font-weight: 500; }
.icon-btn { background: none; border: 1px solid var(--rule); color: var(--ink); border-radius: 8px; width: 34px; height: 34px; cursor: pointer; font-size: 1rem; }
.site-foot { border-top: 1px solid var(--rule); margin-top: 48px; padding: 18px 0; font-size: 0.85rem; }
.site-foot a { color: var(--muted); }
.draft-banner { background: var(--accent); color: var(--accent-ink); text-align: center; padding: 8px 16px; font-size: 0.9rem; }
.draft-banner a { color: inherit; font-weight: 600; }
@media (max-width: 640px) { .sites { display: none; } }

/* buttons */
.btn { font: 500 0.95rem var(--sans); background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent); border-radius: 8px; padding: 8px 14px; cursor: pointer; }
.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--rule); }
.btn.ghost:hover { border-color: var(--muted); filter: none; }
.btn.danger { color: var(--bad); }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--accent-text); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
button:focus-visible, a:focus-visible, input:focus-visible, summary:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }

/* the author's text */
.prose { font-family: var(--serif); font-size: 1.15rem; line-height: 1.65; }
.prose p { margin: 0 0 1em; }
.prose p:last-child { margin-bottom: 0; }
.prose.small { font-size: 0.95rem; line-height: 1.5; }

/* title screen */
.title { max-width: 640px; margin: 48px auto; }
.title h1 { font-family: var(--serif); font-size: clamp(2rem, 6vw, 3rem); font-weight: 600; margin: 0 0 16px; letter-spacing: -0.01em; }
.title .intro { color: var(--ink); margin-bottom: 32px; }
.slots { list-style: none; padding: 0; margin: 0 0 20px; display: grid; gap: 10px; }
.slot { background: var(--surface); border: 1px solid var(--rule); border-radius: 12px; padding: 14px 16px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; box-shadow: var(--shadow); }
.slot.empty { box-shadow: none; background: transparent; border-style: dashed; }
.slot-info { display: flex; flex-direction: column; flex: 1; min-width: 180px; }
.slot-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.name-form { display: flex; gap: 8px; flex: 1; min-width: 220px; }
.name-form input { flex: 1; min-width: 0; }
input { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--rule); border-radius: 8px; padding: 8px 10px; }

/* playing */
.play { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 40px; align-items: start; padding: 24px 0; }
.story { max-width: 680px; }
.story-top { margin-bottom: 18px; font-size: 0.9rem; }
.scene-text { margin-bottom: 28px; }
.events { list-style: none; margin: 0 0 22px; padding: 10px 14px; border-left: 3px solid var(--rule); font-size: 0.92rem; display: grid; gap: 3px; }
.events li.good { color: var(--good); }
.events li.bad { color: var(--bad); }
.events li.big { font-weight: 600; }
.choices { display: grid; gap: 10px; }
.choice { text-align: left; font: 500 1rem/1.4 var(--sans); color: var(--ink); background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; padding: 12px 16px; cursor: pointer; display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 10px; box-shadow: var(--shadow); }
.choice:hover:not(:disabled) { border-color: var(--accent); }
.choice:hover:not(:disabled) > span:first-child { color: var(--accent-text); }
.choice.locked { opacity: 0.55; cursor: not-allowed; box-shadow: none; }
.tag { font: 500 0.75rem var(--mono); color: var(--muted); background: var(--chip); border-radius: 6px; padding: 2px 6px; }

/* the character sheet */
.sheet { position: sticky; top: 16px; }
.sheet-box { background: var(--surface); border: 1px solid var(--rule); border-radius: 12px; padding: 14px 16px; box-shadow: var(--shadow); }
.sheet-box > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; }
.sheet-box > summary::-webkit-details-marker { display: none; }
.sheet-name { font-weight: 600; font-size: 1.1rem; }
.sheet-short { margin-left: auto; display: flex; align-items: center; gap: 8px; font-size: 0.85rem; color: var(--muted); }
.sheet-short .bar { width: 60px; }
.sheet-box[open] .sheet-short { display: none; }
.sheet-box > p { margin: 2px 0 10px; font-size: 0.9rem; }
.sheet h3 { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 16px 0 6px; font-weight: 500; }
.sheet h3 .asi { color: var(--accent-text); text-transform: none; letter-spacing: 0; font-size: 0.85rem; }
.stats, .equip { margin: 0; display: grid; gap: 4px; }
.stats div, .equip div { display: flex; gap: 10px; align-items: center; }
.stats dt, .equip dt { width: 64px; color: var(--muted); font-size: 0.85rem; flex: none; }
.stats dd, .equip dd { margin: 0; display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.stats .bar { flex: 1; }
.bar { display: inline-block; height: 6px; background: var(--chip); border-radius: 3px; overflow: hidden; min-width: 40px; }
.bar > span { display: block; height: 100%; background: var(--good); border-radius: 3px; transition: width 0.3s; }
.bar.low > span, .bar.enemy > span { background: var(--hp); }
.abilities { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.abilities li { position: relative; border: 1px solid var(--rule); border-radius: 8px; padding: 4px 6px; display: grid; grid-template-columns: auto 1fr; align-items: baseline; column-gap: 6px; }
.ab-key { font: 500 0.7rem var(--mono); color: var(--muted); }
.ab-score { font-weight: 600; text-align: right; }
.ab-mod { grid-column: 1 / -1; font-size: 0.75rem; color: var(--muted); text-align: right; }
.plus { position: absolute; top: -8px; right: -8px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink); font-weight: 600; cursor: pointer; line-height: 1; }
.inventory { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; font-size: 0.92rem; }
.inventory li { display: flex; gap: 8px; align-items: baseline; justify-content: space-between; }
.inventory details { flex: 1; min-width: 0; }
.inventory summary { cursor: pointer; }
.inventory .link { font-size: 0.85rem; flex: none; }
.log { margin-top: 16px; font-size: 0.85rem; }
.log summary { cursor: pointer; color: var(--muted); }
.log .events { margin: 8px 0 0; font-size: 0.82rem; }

/* fights */
.combat { display: grid; gap: 16px; }
.round { margin: 0; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.06em; }
.enemies { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.enemies li { background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; padding: 12px 14px; display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; align-items: center; }
.enemies li.down { opacity: 0.45; }
.enemies .enemy-head { display: flex; gap: 10px; align-items: baseline; }
.enemies .enemy-head summary { font-weight: 600; cursor: pointer; }
.enemies .bar { grid-column: 1; width: 100%; }
.enemies .btn { grid-column: 2; grid-row: 1 / span 2; }
.combat .events { margin: 0; }
.combat-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.combat-actions p { width: 100%; margin: 0; }

.ending h2 { font-family: var(--serif); font-size: 1.8rem; margin: 8px 0 12px; }
.ending.death h2 { color: var(--bad); }

/* dialogs */
.dlg { border: 1px solid var(--rule); border-radius: 14px; background: var(--surface); color: var(--ink); padding: 22px; max-width: min(420px, calc(100vw - 32px)); box-shadow: var(--shadow); }
.dlg::backdrop { background: rgb(0 0 0 / 0.4); }
.dlg h2 { margin: 0 0 8px; font-size: 1.2rem; }
.dlg form { display: grid; gap: 12px; }
.dlg label { display: grid; gap: 4px; font-size: 0.9rem; }
.dlg p { margin: 0; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

@media (max-width: 860px) {
  .play { grid-template-columns: 1fr; gap: 16px; padding-top: 12px; }
  .sheet { position: static; order: -1; }
  .prose { font-size: 1.08rem; }
}

.privacy { max-width: 680px; padding-top: 24px; }
.privacy h2 { font-size: 1.1rem; margin-top: 28px; }
