:root {
  --bg: #14161a;
  --panel: #1d2026;
  --panel2: #23262e;
  --text: #e8e6e1;
  --muted: #9aa0ab;
  --green: #5fb36a;
  --yellow: #d9a83f;
  --red: #d95f5f;
  --accent: #7aa2f7;
  --identity: #c792ea;
  /* Текстовые цвета сигналов. Контраст считается по тому фону, на котором текст
     реально лежит: плашка .sig сидит на --panel2 (#23262e), а не на --panel.
     Порог — 4.5:1 (danger-signals §8.2). --red (#d95f5f) на этом фоне даёт
     4.14:1 и для текста не годится. */
  --sig-danger: #e08a8a;   /* 5.89:1 на --panel2 */
  --sig-warn: #f0b955;     /* 8.48:1 на --panel2 */
  --sig-assigned: #b9bec9; /* 7.38:1 на --panel-raised */
  /* Имя про поверхность, а не про тему: это фон приподнятой вставки внутри
     карточки. Оба нынешних потребителя (плашка «Назначено» и блок черты)
     оказались про назначенное последствие — это совпадение сегодняшнего
     набора экранов, опираться на него и переименовывать по теме нельзя. */
  --panel-raised: #2a2d36;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 Georgia, "Times New Roman", serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
}

#app { width: 100%; max-width: 640px; padding: 16px 16px 48px; }

/* Баннер демоверсии: шапка страницы, один абзац для участника плейтеста.
   Приглушён намеренно — это рамка вокруг игры, а не часть её экрана. */
#demo-note {
  width: 100%;
  max-width: 640px;
  padding: 12px 16px;
  border-bottom: 1px solid #2a2d36;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.hud {
  background: var(--panel);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 16px;
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
}
.hud-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
  color: var(--muted);
}
.hud-top .grade { color: var(--accent); font-weight: 600; }
/* Эмодзи-счётчики в верхней строке заменены плашками в полосе сигналов (§4.4) */

.bar-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 3px 0; }
.bar-row .label { width: 128px; color: var(--muted); white-space: nowrap; }
.bar-row .label.identity { color: var(--identity); }
.bar-row .track {
  flex: 1; height: 10px; background: #0e1013; border-radius: 5px; overflow: hidden;
}
.bar-row .fill { height: 100%; border-radius: 5px; transition: width .4s; }
.bar-row .val { width: 34px; text-align: right; font-variant-numeric: tabular-nums; }
/* Заметка под баром (§4.6): цена, которая уже действует. Часть строки бара —
   переносится на вторую строку и выравнивается под шкалой. */
.bar-row .bar-note {
  flex-basis: 100%; margin-left: 136px; margin-top: -1px; margin-bottom: 3px;
  color: var(--muted); font-size: 12px; line-height: 1.35;
}

/* ---------- полоса сигналов опасности (§4, §8) ----------
   Уровень читается словом и значком; цвет и стиль рамки — вторичные признаки:
   Внимание — пунктир, Опасно — толстая сплошная, Назначено — двойная. */
.signals { list-style: none; margin: 10px 0 0; padding: 0; }
.sig {
  display: flex; align-items: flex-start; gap: 8px;
  margin: 6px 0; padding: 6px 10px;
  background: var(--panel2); border-radius: 6px;
  border-left: 3px dashed var(--sig-warn);
  font-size: 13px; line-height: 1.4;
}
.sig-icon {
  flex: 0 0 auto; min-width: 22px; text-align: center;
  font-weight: 700; font-variant-numeric: tabular-nums; color: var(--sig-warn);
}
.sig-body { flex: 1 1 auto; min-width: 0; }
.sig-head { display: block; }
.sig-title { color: var(--text); font-weight: 600; }
.sig-level { color: var(--sig-warn); font-weight: 700; }
.sig-sep { color: var(--muted); }
.sig-text { display: block; color: var(--text); }
.sig-hint { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; }

.sig-danger { border-left: 5px solid var(--sig-danger); }
.sig-danger .sig-icon, .sig-danger .sig-level { color: var(--sig-danger); }
.sig-assigned { border-left: 5px double var(--sig-assigned); background: var(--panel-raised); }
.sig-assigned .sig-icon, .sig-assigned .sig-level { color: var(--sig-assigned); }
.sig-counter { border-left: 3px solid var(--muted); }
.sig-counter .sig-icon { color: var(--muted); }
.sig-inline { margin: 4px 0 10px; font-family: "Segoe UI", system-ui, sans-serif; }

.card {
  background: var(--panel);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 14px;
}
.card h2 { font-size: 20px; margin-bottom: 10px; }
.card .kicker {
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 12px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); margin-bottom: 6px;
}
.card p.flavor { margin-bottom: 14px; }

button.choice {
  display: block; width: 100%; text-align: left;
  background: var(--panel2); color: var(--text);
  border: 1px solid #333845; border-radius: 8px;
  padding: 10px 14px; margin: 8px 0;
  font: inherit; cursor: pointer;
}
button.choice:hover:not(:disabled) { border-color: var(--accent); }
button.choice:focus-visible, .devbar:focus-visible {
  outline: 3px solid var(--accent); outline-offset: 2px; border-color: var(--accent);
}
/* Заголовок карточки принимает фокус после каждого рендера (§8.4) */
.card h1:focus-visible, .card h2:focus-visible {
  outline: 2px dashed var(--accent); outline-offset: 4px;
}
.card h1:focus:not(:focus-visible), .card h2:focus:not(:focus-visible) { outline: none; }
button.choice:disabled { opacity: .45; cursor: not-allowed; }
button.choice .lock {
  display: block; font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 12px; color: var(--yellow);
}
button.choice .hint {
  display: block; font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 12px; color: var(--muted);
}

.deltas {
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 13px; margin: 8px 0 2px;
}
.deltas span { margin-right: 10px; white-space: nowrap; }
.d-up { color: var(--green); }
/* Отрицательная дельта — текст 13 px в .deltas и 14 px в колонке table.summary,
   оба appendChild'ятся прямо в .card, то есть лежат на --panel. --red (#d95f5f)
   даёт на этом фоне 4.47 при пороге 4.5 и не проходит; красный здесь берётся из
   текстовой пары: --sig-danger даёт 6.35, вровень с --green у .d-up (6.33).
   Имя токена говорит про сигнал, а дельта сигналом не является: общее у
   потребителей одно — это тот красный, который проходит как текст. Переименование
   отложено сознательно (§8.2 danger-signals.md называет токен поимённо).
   После этой правки var(--red) остаётся у одного потребителя — zoneColor()
   в app.js, заливка шкалы, нетекстовое требование. */
.d-down { color: var(--sig-danger); }

table.summary { width: 100%; border-collapse: collapse; font-family: "Segoe UI", system-ui, sans-serif; font-size: 14px; }
table.summary td { padding: 4px 6px; border-bottom: 1px solid #2b2f38; }
table.summary td.num { text-align: right; font-variant-numeric: tabular-nums; }

.notes { color: var(--yellow); font-family: "Segoe UI", system-ui, sans-serif; font-size: 13px; margin-top: 10px; }

/* ---------- итоги квартала: риски и примечания ---------- */
.risk-changes { margin-top: 16px; font-family: "Segoe UI", system-ui, sans-serif; }
.risk-changes .kicker { margin-bottom: 8px; }
.risk-changes .signals { margin-top: 0; }
.risk-sub {
  font-size: 12px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); margin: 10px 0 4px;
}
.risk-list { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.risk-list li { padding: 2px 0 2px 12px; border-left: 2px solid #333845; margin: 3px 0; }
.border-line {
  margin: 8px 0 0; padding: 8px 10px; font-size: 13px; line-height: 1.45;
  color: var(--text); background: var(--panel-raised); border-radius: 6px;
}
/* Пометка §4.9 — сообщение о прошлом, вне сигналов и вне блока рисков */
.stale-note { margin-top: 12px; font-family: "Segoe UI", system-ui, sans-serif; }
.stale-note .kicker { margin-bottom: 2px; }
.stale-note p { color: var(--muted); font-size: 13px; line-height: 1.4; }

/* Сообщение о судьбе сохранения (было инлайном в app.js, T02) */
.notice {
  margin: 12px 0 16px; padding: 10px 12px;
  border-left: 3px solid var(--yellow);
  background: rgba(216, 161, 58, .12);
  font-family: "Segoe UI", system-ui, sans-serif; font-size: 14px; line-height: 1.4;
}
.muted { color: var(--muted); }
/* ---------- экран финала (T04) ---------- */
.ending h1 { font-size: 26px; margin-bottom: 8px; }
.ending ul { margin: 10px 0 0 20px; }
/* На финале кикер работает заголовком раздела и повторяется пять раз подряд.
   Без отступа сверху каждый следующий прилипал к предыдущему блоку. */
.ending .kicker:not(:first-child) { margin-top: 20px; }
/* Таблица финала двухколоночная: имя и число. Без ширины первая колонка
   растягивалась на всё свободное место (table.summary писалась под четыре). */
.ending table.summary td:first-child { width: 60%; }
/* Три списка финала идут подряд и отличались только шапкой. Развожу их стилем
   полосы слева — он читается без цвета (§8.1), оттенок приглушённый и служит
   различением раздела, а не оценкой: вывод делает игрок (Pillar 4). */
.ending ul.flag-list { list-style: none; margin: 8px 0 0; padding: 0; }
.ending ul.flag-list li {
  margin: 4px 0; padding: 3px 0 3px 10px;
  border-left: 3px solid #3a4050;
}
.ending ul.flag-costs li { border-left-style: solid; border-left-color: #7d6a52; }
.ending ul.flag-gains li { border-left: 5px double #5f7d68; }
.ending ul.flag-marks li { border-left-style: dotted; border-left-color: #59606e; }

.devbar {
  font-family: "Segoe UI", system-ui, sans-serif; font-size: 12px;
  color: var(--muted); margin-top: 20px; cursor: pointer; user-select: none;
}
.devpanel {
  font-family: ui-monospace, monospace; font-size: 12px;
  background: #0e1013; border-radius: 8px; padding: 10px; margin-top: 6px;
  white-space: pre-wrap; color: var(--muted);
}

/* ---------- узкий экран (~400 px, §8.5) ---------- */
@media (max-width: 480px) {
  #app { padding: 12px 12px 40px; }
  #demo-note { padding: 10px 12px; font-size: 13px; }
  .card { padding: 16px 14px; }
  .bar-row .label { width: 96px; white-space: normal; }
  .bar-row .bar-note { margin-left: 104px; }
  .sig { padding: 6px 8px; }
}
@media (max-width: 360px) {
  .bar-row .bar-note { margin-left: 0; }
}

/* ---------- уважение к «поменьше движения» (§8.6) ---------- */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  .bar-row .fill { transition: none; }
}
