:root {
  --bg: #11110f;
  --surface: #191816;
  --line: #2b2a26;
  --line-2: #3d3b36;
  --text: #e6e1d6;
  --muted: #8a857a;
  --faint: #5f5b53;
  --accent: #b23a32;
  --serif: 'PT Serif', Georgia, 'Times New Roman', serif;
  --mono: 'PT Mono', ui-monospace, Menlo, monospace;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 16px/1.6 var(--serif); min-height: 100vh; overscroll-behavior: none; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
[hidden] { display: none !important; }
p { margin: 0 0 0.85em; }
p:last-child { margin-bottom: 0; }

#app { max-width: 600px; margin: 0 auto; padding: 0 20px calc(88px + var(--safe-b)); }

/* ---------- типографика ---------- */
.label { font: 11px/1.4 var(--mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.label.accent { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 14px; line-height: 1.5; }
.mono { font-family: var(--mono); }
.center { text-align: center; }

/* ---------- шапка ---------- */
.top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 18px 0 14px; border-bottom: 1px solid var(--line); }
.top .phase { color: var(--text); text-align: right; }
.title { font: 700 30px/1.15 var(--serif); margin: 28px 0 6px; letter-spacing: -0.01em; }
.lead { color: var(--muted); margin: 0 0 8px; }

/* ---------- блоки ---------- */
.sec { margin-top: 36px; }
.sec > .label { display: block; padding-bottom: 10px; border-bottom: 1px solid var(--line); }

.doc { padding: 20px 0 22px; border-bottom: 1px solid var(--line); }
.doc:last-child { border-bottom: 0; }
.doc h3 { font: 700 21px/1.25 var(--serif); margin: 6px 0 12px; }
.doc .q { margin-top: 16px; padding-left: 14px; border-left: 2px solid var(--line-2); color: var(--muted); font-style: italic; }
.doc ul { margin: 0; padding-left: 1.1em; }
.doc li { margin: 0.35em 0; }
.doc .sub { margin-top: 18px; }
.doc .sub:first-child { margin-top: 0; }

.box { border: 1px solid var(--line); border-radius: 4px; padding: 16px; }
.box + .box { margin-top: 12px; }
.box.alert { border-color: var(--accent); }
.box.alert .label { color: var(--accent); }
.killer-word { font: 700 26px/1.2 var(--serif); margin: 4px 0 6px; }

.timeline { list-style: none; padding: 0; margin: 0 0 0.85em; }
.doc p + .timeline, .timeline + p { margin-top: 0.85em; }
.timeline li { display: grid; grid-template-columns: 58px 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.timeline li:last-child { border-bottom: 0; }
.timeline .t { font: 13px/1.7 var(--mono); color: var(--muted); }

/* ---------- списки ---------- */
.rows { border-top: 1px solid var(--line); }
.row-item { display: grid; grid-template-columns: 40px 1fr auto; gap: 12px; align-items: center; width: 100%; text-align: left; padding: 14px 0; border-bottom: 1px solid var(--line); }
.row-item .no { font: 13px var(--mono); color: var(--muted); }
.row-item .ttl { font-weight: 700; }
.row-item .meta { font-size: 14px; color: var(--muted); }
.row-item .arr { color: var(--faint); font-family: var(--mono); }
.row-plain { display: flex; align-items: baseline; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.row-plain:last-child { border-bottom: 0; }
.row-plain .grow { flex: 1; min-width: 0; }

.mark { font: 11px var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.mark.on { color: var(--text); }
.mark.accent { color: var(--accent); }

.person { padding: 18px 0; border-bottom: 1px solid var(--line); }
.person:last-child { border-bottom: 0; }
.person .head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.person h3 { font: 700 19px/1.3 var(--serif); margin: 0; }
.person p { margin: 8px 0 0; font-size: 15px; }

.progress { height: 2px; background: var(--line); margin-top: 14px; }
.progress > i { display: block; height: 100%; background: var(--text); }

/* ---------- кнопки и поля ---------- */
.btn { display: block; width: 100%; padding: 14px 16px; border-radius: 4px; text-align: center; background: var(--text); color: var(--bg); font: 700 15px var(--serif); transition: opacity 0.15s; }
.btn:active { opacity: 0.8; }
.btn[disabled] { opacity: 0.35; }
.btn.line { background: transparent; color: var(--text); border: 1px solid var(--line-2); }
.btn.danger { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.btn.sm { display: inline-block; width: auto; padding: 7px 12px; font-size: 14px; }
.stack > * + * { margin-top: 10px; }
.pair { display: flex; gap: 10px; }
.pair > * { flex: 1; }

.input { width: 100%; padding: 13px 14px; border-radius: 4px; background: var(--surface); border: 1px solid var(--line-2); outline: none; }
.input:focus { border-color: var(--muted); }
.input.code { font: 18px var(--mono); letter-spacing: 0.3em; text-transform: uppercase; text-align: center; }
textarea.input { min-height: 50vh; resize: vertical; line-height: 1.55; }
.field { display: block; margin-bottom: 8px; }

.choice { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice button { padding: 13px 10px; border: 1px solid var(--line-2); border-radius: 4px; text-align: center; }
.choice button.on { border-color: var(--text); background: var(--surface); }

.check { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--text); flex: none; }

/* ---------- закрытая роль ---------- */
.locked { padding: 28px 0; border-bottom: 1px solid var(--line); text-align: center; }
.locked p { color: var(--muted); max-width: 32ch; margin: 0 auto 18px; }
.locked .btn { display: inline-block; width: auto; padding: 12px 22px; }

/* ---------- голосование ---------- */
.vote-q { padding: 20px 0; border-bottom: 1px solid var(--line); }
.vote-q .qt { font-weight: 700; margin-bottom: 12px; }
.opts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.opt { padding: 10px 12px; border: 1px solid var(--line); border-radius: 4px; text-align: left; line-height: 1.3; }
.opt small { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }
.opt.on { border-color: var(--text); background: var(--surface); }

/* ---------- развязка ---------- */
.score { display: grid; grid-template-columns: 28px 1fr auto; gap: 12px; align-items: baseline; padding: 12px 0; border-bottom: 1px solid var(--line); }
.score:last-child { border-bottom: 0; }
.score .pl { font: 13px var(--mono); color: var(--muted); }
.score .pts { font: 18px var(--mono); }
.letter { font-style: italic; font-size: 17px; line-height: 1.7; }
.letter .sign { text-align: right; font-style: normal; font-family: var(--mono); letter-spacing: 0.1em; }

/* ---------- ведущий ---------- */
.steps { list-style: none; margin: 0; padding: 0; }
.steps li { display: grid; grid-template-columns: 28px 1fr; padding: 9px 0; border-bottom: 1px solid var(--line); color: var(--faint); }
.steps li:last-child { border-bottom: 0; }
.steps li .n { font: 13px/1.7 var(--mono); }
.steps li.done { color: var(--muted); }
.steps li.cur { color: var(--text); }
.steps li.cur .n { color: var(--accent); }
.linkbox { font: 13px var(--mono); word-break: break-all; padding: 12px; border: 1px dashed var(--line-2); border-radius: 4px; color: var(--muted); }

/* ---------- нижняя навигация ---------- */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--bg); border-top: 1px solid var(--line); padding-bottom: var(--safe-b); }
.tabs .in { display: flex; max-width: 600px; margin: 0 auto; }
.tabs button { flex: 1; padding: 16px 2px 18px; color: var(--faint); font: 11px var(--mono); letter-spacing: 0.1em; text-transform: uppercase; position: relative; }
.tabs button.on { color: var(--text); }
.tabs button.on::before { content: ''; position: absolute; top: -1px; left: 22%; right: 22%; height: 2px; background: var(--accent); }

/* ---------- модалка и тост ---------- */
.modal { position: fixed; inset: 0; z-index: 50; background: var(--bg); overflow-y: auto; padding: 0 20px calc(28px + var(--safe-b)); }
.modal .inner { max-width: 600px; margin: 0 auto; }
.modal .bar { position: sticky; top: 0; z-index: 1; background: var(--bg); display: flex; justify-content: space-between; align-items: center; padding: 16px 0; border-bottom: 1px solid var(--line); }
.modal .close { font: 11px var(--mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); padding: 6px 0; }

.toast { position: fixed; left: 50%; bottom: calc(76px + var(--safe-b)); transform: translateX(-50%); z-index: 60; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 4px; font-size: 14px; max-width: calc(100vw - 40px); text-align: center; }
.toast.err { background: var(--accent); color: #fff; }

.splash { min-height: 70vh; display: grid; place-content: center; }

details.rules summary { cursor: pointer; list-style: none; padding: 14px 0; border-bottom: 1px solid var(--line); }
details.rules summary::-webkit-details-marker { display: none; }
details.rules summary::after { content: '+'; float: right; font-family: var(--mono); color: var(--muted); }
details.rules[open] summary::after { content: '−'; }
details.rules ol { padding-left: 1.2em; margin: 14px 0 0; }
details.rules li { margin: 0.5em 0; }
