:root {
  --bg: #f7f3ea;
  --card: #fffdf8;
  --ink: #2b2620;
  --muted: #6e655a;
  --line: #ddd3c3;
  --accent: #7a3b2e;
  --accent-ink: #ffffff;
  --soft: #f0e6d6;
  --good: #2f7a3d;
  --warn-bg: #fff1c7;
  --warn-ink: #5a4300;
  --bad: #b3261e;
  --story-font: Georgia, "Iowan Old Style", "Times New Roman", serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1916;
    --card: #25221e;
    --ink: #ece6dc;
    --muted: #a99f92;
    --line: #3d3832;
    --accent: #e0a08f;
    --accent-ink: #1b1916;
    --soft: #302b25;
    --good: #7fcf8c;
    --warn-bg: #4a3b10;
    --warn-ink: #ffe7a3;
    --bad: #ff8a80;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }

.top {
  max-width: 760px;
  margin: 0 auto;
  padding: 16px 16px 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.top .brand {
  font-family: var(--story-font);
  font-size: 24px;
  font-weight: bold;
  color: var(--accent);
  text-decoration: none;
}
.top nav { display: flex; gap: 16px; align-items: center; font-size: 15px; }
.linklike { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; cursor: pointer; font-size: 15px; }

main { max-width: 760px; margin: 0 auto; padding: 8px 16px 64px; }

h1 { font-family: var(--story-font); font-size: 30px; line-height: 1.2; margin: 16px 0 8px; overflow-wrap: anywhere; }
h2 { font-size: 20px; margin: 28px 0 8px; }
.card h2 { margin-top: 0; }
.lead { font-size: 18px; }
.hint { color: var(--muted); font-size: 15px; margin: 6px 0; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  margin: 16px 0;
}
.card > :first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }

label { display: block; font-weight: 600; margin: 14px 0 6px; }
label.check { display: flex; gap: 8px; align-items: flex-start; font-weight: normal; margin: 8px 0; cursor: pointer; }
label.check input { margin-top: 5px; width: 18px; height: 18px; flex: none; }
label.check.big { font-weight: 600; font-size: 18px; }

input, textarea, button, select { font: inherit; color: inherit; }
input:not([type="checkbox"]), textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  padding: 10px 12px;
}
textarea { font-family: var(--story-font); font-size: 18px; line-height: 1.6; resize: vertical; min-height: 220px; }

button, .button {
  display: inline-block;
  border: 1px solid var(--line);
  background: var(--soft);
  border-radius: 8px;
  padding: 10px 16px;
  cursor: pointer;
  text-decoration: none;
  color: var(--ink);
}
button.primary, .button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.danger { color: var(--bad); }
button:disabled { opacity: 0.55; cursor: default; }
button.small { padding: 4px 10px; font-size: 14px; }
.wide { width: 100%; margin-top: 14px; }

.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0; }
.row.spread { justify-content: space-between; }
.linkrow { display: flex; gap: 8px; }
.linkrow input { min-width: 0; flex: 1; font-size: 14px; }

.toast {
  position: sticky;
  top: 8px;
  z-index: 10;
  background: var(--warn-bg);
  color: var(--warn-ink);
  border-radius: 8px;
  padding: 10px 14px;
  margin: 8px 0;
}
.banner {
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: 12px;
  padding: 12px 16px;
  margin: 16px 0;
  font-weight: 600;
}

/* Landing page */
.modes { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; margin: 16px 0; }
.mode { display: flex; flex-direction: column; margin: 0; }
.mode h3 { font-family: var(--story-font); font-size: 22px; margin: 0 0 4px; }
.mode .tagline { color: var(--accent); font-weight: 600; font-size: 15px; margin: 0 0 8px; }
.mode p { margin: 0 0 12px; }
.mode .button { margin-top: auto; text-align: center; }

.items { list-style: none; margin: 0; padding: 0; }
.items li { border-bottom: 1px solid var(--line); }
.items li:first-child { border-top: 1px solid var(--line); }
.items a.item { display: block; padding: 12px 4px; text-decoration: none; color: var(--ink); }
.items a.item:hover { background: var(--soft); }
.items .title { font-family: var(--story-font); font-size: 19px; font-weight: bold; overflow-wrap: anywhere; }
.items .meta { color: var(--muted); font-size: 14px; }
.badge {
  display: inline-block;
  font-family: system-ui, sans-serif;
  font-size: 12px;
  font-weight: 600;
  border-radius: 999px;
  padding: 2px 8px;
  margin-left: 6px;
  vertical-align: 3px;
  background: var(--soft);
  color: var(--muted);
}
.badge.hot { background: var(--accent); color: var(--accent-ink); }
.empty { color: var(--muted); font-style: italic; }

/* Stories */
.story {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
  font-family: var(--story-font);
  font-size: 19px;
  line-height: 1.7;
}
.story .piece { margin: 0 0 1.1em; }
.story .piece:last-child { margin-bottom: 0; }
.story .author { font-family: system-ui, sans-serif; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.story .text { white-space: pre-wrap; overflow-wrap: anywhere; }
.story.hide-names .author { display: none; }
.story .empty { font-family: system-ui, sans-serif; font-size: 16px; }

/* Players */
.players { list-style: none; padding: 0; margin: 0; }
.players li { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 0; border-bottom: 1px solid var(--line); }
.players .name { font-weight: 600; }
.players .turn-mark { width: 1.2em; color: var(--accent); }
.players .tag { font-size: 13px; color: var(--muted); }
.players .tag.good { color: var(--good); }

.counter { font-variant-numeric: tabular-nums; }
.counter.over { color: var(--bad); font-weight: 600; }
.saved { color: var(--muted); font-size: 14px; }

details { margin: 16px 0; }
summary { cursor: pointer; font-weight: 600; }
.danger-zone { border-color: var(--bad); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
