/* «Макулатура», прототип: панели интерфейса поверх холста. Палитра — из макета питча. */
:root {
  --floor: #DDE3E8;
  --text: #2B303A;
  --muted: #6B7688;
  --faint: #9AA4B2;
  --panel: #F7F8FA;
  --panel-edge: #C6CED8;
  --chip: #E6EBF1;
  --blue: #4A78C2;
  --green: #5AA469;
  --ok: #4E9B5D;
  --warn: #E7A23B;
  --bad: #D9543F;
  --calm: #8DA2BF;          /* «запас полон»: сделал сколько влезло и ждёт */
  --type: #7B5EA7;          /* литеры и наборная — узкое место эпохи */
  --type-light: #B9A6D6;
  --idle: #B4BDC9;
  --wood: #A87B52;
  --shadow: 0 4px 14px rgba(28, 38, 56, 0.18);
  --ui: "Golos Text", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  --book: "Old Standard TT", Georgia, serif;
  --side-w: 262px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;   /* a sideways swipe over a panel must not take the browser «back» */
  background: #C3CBD4;
  color: var(--text);
  font: 13px/1.35 var(--ui);
  -webkit-font-smoothing: antialiased;
}

#world {
  position: fixed;
  inset: 0;
  display: block;
  cursor: default;
  touch-action: none;
}

/* The live scene (0.4.0) lies under #world, which keeps the mouse and draws what is over the scene. */
#scene {
  position: fixed;
  inset: 0;
  display: block;
  pointer-events: none;
}
#scene[hidden] { display: none; }

/* «Готовлю вид…» in the middle of the map while the scene builds the programs of a style (view3d.js): the page stands
   still for up to a second and a half then. */
.scene-prep {
  position: fixed;
  left: max(90px, calc(50% - (var(--side-w) + 22px) / 2));
  top: 45%;
  transform: translate(-50%, -50%);
  z-index: 7;
  padding: 8px 16px;
  border-radius: 9px;
  background: rgba(33, 38, 48, 0.9);
  color: #fff;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: var(--shadow);
  pointer-events: none;
}
.scene-prep[hidden] { display: none; }

button { font: inherit; color: inherit; }

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.kicker {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------------------------------------------------------------- top bar */

.topbar {
  position: fixed;
  left: 0; right: 0; top: 0;
  height: 44px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 14px;
  background: rgba(247, 248, 250, 0.97);
  border-bottom: 1px solid var(--panel-edge);
  box-shadow: 0 2px 0 rgba(28, 38, 56, 0.06);
  z-index: 5;
  white-space: nowrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 900;
  font-size: 13px;
  letter-spacing: 1.5px;
  padding-right: 16px;
  border-right: 1px solid var(--panel-edge);
}
.ver { font: 500 10.5px var(--mono); letter-spacing: 0; color: var(--faint); margin-left: -2px; }
.spines { display: inline-flex; align-items: flex-end; gap: 1px; height: 16px; }
.spines i { display: block; width: 4px; border-radius: 1px; }
.spines i:nth-child(1) { height: 13px; background: #D9543F; }
.spines i:nth-child(2) { height: 16px; background: #4A78C2; }
.spines i:nth-child(3) { height: 13px; background: #E7A23B; }

.res { display: flex; align-items: center; gap: 7px; color: var(--muted); font-weight: 500; }
.res b { font: 700 13px var(--mono); color: var(--text); }
.res-icon { width: 20px; height: 20px; border-radius: 5px; background: var(--chip); position: relative; flex: none; }
.res-paper::after { content: ""; position: absolute; left: 5px; top: 3px; width: 10px; height: 13px; background: #fff; border: 1px solid #9AA5B5; border-radius: 1px; }
.res-ink::after { content: ""; position: absolute; left: 5px; top: 5px; width: 10px; height: 11px; background: #23262D; border-top: 3px solid #5B6270; border-radius: 2px; }
.res-type::after { content: ""; position: absolute; left: 4px; top: 4px; width: 12px; height: 11px; background: repeating-linear-gradient(90deg, #7C8391 0 3px, transparent 3px 4.5px); border-bottom: 2px solid #4A505C; }
.res-books::after { content: ""; position: absolute; left: 4px; top: 4px; width: 12px; height: 13px; background: linear-gradient(90deg, #A8433A 0 3.5px, transparent 3.5px 4.5px, #2F4A7A 4.5px 8px, transparent 8px 9px, #C8963E 9px 12px); border-radius: 1px; }

.spacer { flex: 1; }

.era { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.era-badge { background: #2B303A; color: #fff; border-radius: 9px; padding: 2px 9px; font-size: 11px; font-weight: 700; letter-spacing: 0.8px; }

.btn {
  border: 1px solid var(--panel-edge);
  background: #fff;
  border-radius: 8px;
  padding: 5px 12px;
  cursor: pointer;
  font-weight: 600;
}
.btn:hover { border-color: #9FB0C6; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.4; cursor: default; border-color: var(--panel-edge); }
.btn:focus-visible, .seg button:focus-visible, .tool:focus-visible, .link:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
.btn-accent { background: #2B303A; color: #fff; border-color: #2B303A; }
.btn-accent:hover { background: #3A4250; }

.link { border: 0; background: none; padding: 2px 4px; cursor: pointer; color: var(--blue); font-weight: 600; }
.link.danger { color: #B2483B; }

/* ---------------------------------------------------------------- right column */

.side {
  position: fixed;
  right: 10px;
  top: 54px;
  bottom: 10px;
  width: var(--side-w);
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 4;
  overflow-y: auto;          /* on a short window the column scrolls instead of squeezing the list to nothing */
  scrollbar-width: thin;
  overscroll-behavior: contain;
}

.stage {
  flex: 1;
  min-height: 300px;
  display: flex;
  flex-direction: column;
  padding: 12px 14px 12px;
}
.first-order .stage { flex: none; min-height: 0; }
.stage-head { display: flex; align-items: baseline; justify-content: space-between; margin-top: 2px; }
.stage-head h2 { margin: 0; font-size: 19px; font-weight: 700; }
.stage-head .count { white-space: nowrap; margin-left: 8px; }
.count { font: 700 14px var(--mono); }
.progress { height: 6px; border-radius: 3px; background: #E1E6EC; margin: 8px 0 10px; overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: var(--green); border-radius: 3px; }

.shelf { width: 100%; height: 72px; display: block; flex: none; }

.books {
  list-style: none;
  margin: 10px -6px 0 0;
  padding: 8px 6px 0 0;
  border-top: 1px solid var(--panel-edge);
  overflow-y: auto;
  flex: 1;
  min-height: 60px;
  scrollbar-width: thin;
  overscroll-behavior: contain;
}
.books li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 4px;
  border-radius: 5px;
  color: var(--muted);
  min-height: 21px;
  transition: background 2.4s ease;
}
.books li .dot {
  width: 13px; height: 13px; border-radius: 50%; flex: none;
  border: 1.5px solid #B4BDC9;
  position: relative;
}
.books li.got { color: var(--text); font-weight: 500; }
.books li.got .dot { background: var(--green); border-color: var(--green); }
.books li.got .dot::after {
  content: ""; position: absolute; left: 3.5px; top: 1px; width: 3px; height: 6px;
  border: solid #fff; border-width: 0 1.8px 1.8px 0; transform: rotate(45deg);
}
.books li { cursor: pointer; }
.books li:hover:not(.got) { background: #EDF1F6; }
.books li.got { cursor: default; }
.books li .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.books li .tag { font-size: 10px; font-weight: 700; letter-spacing: 0.4px; text-transform: uppercase; color: #fff; background: var(--blue); border-radius: 4px; padding: 1px 5px; }
.books li .tag.print { background: var(--bad); }
.books li .tag.next { background: #fff; color: var(--type); box-shadow: inset 0 0 0 1px var(--type); }
.books li.fresh { background: rgba(90, 164, 105, 0.28); transition: none; }

/* The chain of the order of the prologue (ui.js setupOrder): a row per building, from the order down to the raw
   materials; the dot is the state of the buildings of that kind, hollow while none stands. */
.chain { list-style: none; margin: 10px 0 0; padding: 7px 0 0; border-top: 1px solid var(--panel-edge); flex: none; }
.chain li {
  display: grid; grid-template-columns: 9px 1fr auto; column-gap: 8px; align-items: center;
  padding: 3px 5px; margin: 0 -5px; border-radius: 5px; cursor: pointer;
}
.chain li:hover { background: #EDF1F6; }
.chain .c-name { font-weight: 600; }
.chain .c-count { font: 700 12px var(--mono); }
.chain .c-does { grid-column: 2 / 4; font-size: 11.5px; line-height: 1.3; color: var(--muted); }
.sdot.none { background: transparent; box-shadow: inset 0 0 0 1.5px var(--idle); }
.order-wait { font-weight: 600; margin-top: 4px; padding-left: 8px; border-left: 3px solid var(--calm); }
.order-wait.st-ok { border-color: var(--ok); }
.order-wait.st-warn { border-color: var(--warn); }
.order-wait.st-bad { border-color: var(--bad); }
.order-act { margin-top: 3px; padding-left: 11px; }
.order-reward { margin-top: 10px; }

.stage-foot { border-top: 1px solid var(--panel-edge); padding-top: 9px; margin-top: 8px; flex: none; }
.reward { font-weight: 600; margin-top: 3px; }
.colophon { font: italic 14px/1.4 var(--book); color: var(--text); margin-top: 4px; }
.done-title { font: 700 16px var(--book); }

.press { flex: none; padding: 11px 14px 12px; }
.press-body { margin-top: 7px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.press-row { display: flex; align-items: center; gap: 8px; min-height: 18px; min-width: 0; }
.press-row .lbl { width: 72px; flex: none; color: var(--muted); font-size: 12px; }
.press-row .val { flex: 1; min-width: 0; font-weight: 500; line-height: 1.25; }
/* second line under a row: title may be cut, the numbers never are */
.press-sub { margin: -4px 0 0 97px; min-width: 0; line-height: 1.3; }
.press-sub .title { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--book); font-size: 13px; }
.press-sub .nums { display: block; font: 500 11px var(--mono); color: var(--muted); }
.press-body .press-sub + .press-row { margin-top: 2px; }
.sdot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--warn); }
.sdot.ok { background: var(--ok); }
.sdot.warn { background: var(--warn); }
.sdot.bad { background: var(--bad); }
.sdot.calm { background: var(--calm); }
.sdot.type { background: var(--type); box-shadow: 0 0 0 2px rgba(123, 94, 167, 0.25); }
.sdot.idle { background: var(--faint); }     /* the same grey as the dot on the sprite */
.bar { height: 5px; border-radius: 3px; background: #E1E6EC; overflow: hidden; margin: -1px 0 2px 97px; }
.bar i { display: block; height: 100%; background: var(--type); }
.bar.dist i { background: var(--type-light); }
.cases { display: grid; grid-template-columns: repeat(20, minmax(0, 1fr)); gap: 2px; flex: 1; min-width: 0; }
.cases i { height: 7px; border-radius: 1.5px; background: #D5DCE4; }
.cases i.on { background: var(--type); }
.cases i.on.p2 { background: var(--type-light); }
.press-note { font-size: 12px; color: var(--muted); }
.press-note b { font: 700 12px var(--mono); color: var(--text); }

/* ---------------------------------------------------------------- bottom: toolbar and controls */

.bottom {
  position: fixed;
  left: 12px;
  right: calc(var(--side-w) + 22px);
  bottom: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 4;
  pointer-events: none;
}
/* the toolbar and the controls share a row; on a narrow window the controls wrap under the toolbar */
.bottom-row { display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-end; gap: 8px 10px; max-width: 100%; }
.bottom-row > * { pointer-events: auto; }

/* A grid (0.5.0): the first row of buttons below, the second row of the campaign over it, each ⇧-digit over its digit.
   The spacing is margins, not gaps of the grid: a hidden button leaves no gap behind (ui.js setupToolbar). */
.toolbar { display: grid; grid-template-rows: auto auto; align-items: end; padding: 5px 2.5px; }
.tool {
  grid-row: 2;
  margin: 0 2.5px;
  position: relative;
  width: 44px; height: 44px;
  border: 1px solid #D5DCE4;
  background: #EEF1F5;
  border-radius: 7px;
  padding: 0;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.tool:hover { border-color: #9FB0C6; }
.tool[hidden] { display: none; }
.tool.on { background: #E4ECF9; border: 2px solid var(--blue); }
.tool .key { position: absolute; left: 4px; top: 2px; font: 700 10px var(--mono); color: var(--faint); }
/* «Shift+1» on Windows: across the top of the button, the picture a little lower (playtest of 0.3.0, item 14) */
.tool .key.long { left: 2px; right: 2px; top: 1px; text-align: center; font-size: 9px; letter-spacing: -0.2px; }
.tool.long-key canvas { margin-top: 12px; }
.tool.on .key { color: var(--blue); }
.tool canvas { margin-top: 6px; }
.tool.row2 { grid-row: 1; margin-bottom: 5px; }
.tool-sep { grid-row: 2; align-self: stretch; width: 1px; background: var(--panel-edge); margin: 4px 2px; }

.controls { display: flex; align-items: center; gap: 8px; padding: 8px 10px; height: 56px; }
.btn.icon { width: 34px; height: 30px; padding: 0; display: flex; align-items: center; justify-content: center; color: var(--text); }
.btn.icon.on { background: #E4ECF9; border-color: var(--blue); color: var(--blue); }
.ctl-sep { width: 1px; height: 24px; background: var(--panel-edge); margin: 0 2px; }
.ico-pause { width: 10px; height: 12px; border-left: 3.5px solid var(--text); border-right: 3.5px solid var(--text); }
.ico-play { width: 0; height: 0; border-left: 11px solid var(--text); border-top: 7px solid transparent; border-bottom: 7px solid transparent; margin-left: 3px; }
.seg { display: flex; border: 1px solid var(--panel-edge); border-radius: 8px; overflow: hidden; background: #fff; }
.seg button { border: 0; background: none; padding: 5px 9px; cursor: pointer; font: 600 12px var(--mono); color: var(--muted); }
.seg button + button { border-left: 1px solid var(--panel-edge); }
.seg button.on { background: #E4ECF9; color: var(--blue); }
.clock { font: 700 13px var(--mono); min-width: 44px; text-align: right; }
.pause-notice {
  position: fixed;
  top: 64px;
  left: 16px;
  z-index: 5;
  padding: 12px 18px;
  border: 2px solid var(--warn);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  font-size: 16px;
  font-weight: 700;
  pointer-events: none;
}

.paused .clock { color: var(--bad); }

/* the line above the toolbar: what the tool or the load does, with ↺ ↻ ⇋ for turning and mirroring */
.tool-hint {
  display: flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  background: rgba(33, 38, 48, 0.9);
  color: #fff;
  border-radius: 7px;
  padding: 3px 4px 3px 10px;
  pointer-events: auto;
}
.tool-hint[hidden] { display: none; }
/* a hint too long for a small window wraps to a second line instead of losing its end (playtest of 0.3.0, item 14) */
.hint-text {
  min-width: 0;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-height: 1.3;
  font-size: 12px;
  font-weight: 500;
  padding-right: 6px;
}
.hint-btn {
  flex: none;
  width: 28px; height: 22px;
  border: 0;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}
.hint-btn:hover { background: rgba(255, 255, 255, 0.28); }
.hint-btn:focus-visible { outline: 2px solid #9DBBF0; outline-offset: 1px; }
.hint-btn[hidden] { display: none; }

/* ---------------------------------------------------------------- help, tooltip, toast */

/* Top of the map area between the left edge and the right column: the help card with the button «Названия» left of it,
   then toasts. The card keeps to the right, so the raw-material zones on the left (where the first building goes)
   stay open at any window width; toasts are centred. */
.top-stack {
  position: fixed;
  top: 54px;
  left: 12px;
  right: calc(var(--side-w) + 22px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 6;
  pointer-events: none;
}
/* its first line, kept to the right: «Названия», then the card or its button «Как играть» */
.top-row { align-self: stretch; display: flex; justify-content: flex-end; align-items: flex-start; gap: 8px; }
.help {
  width: min(600px, calc(100% - 170px));
  max-height: calc(100vh - 190px);
  overflow-y: auto;
  scrollbar-width: thin;
  padding: 9px 13px 9px;
  font-size: 12px;
  pointer-events: auto;
  overscroll-behavior: contain;
}
.help p { margin: 6px 0; }
.help-head { display: flex; justify-content: space-between; align-items: center; }
.help[hidden] { display: none; }
.help-keys { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 12px; margin: 8px 0 0; }
.help-keys dt { color: var(--muted); font-weight: 600; }
.help-keys dd { margin: 0; }
/* legends of the side marks and of the status dot */
.legend { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 4px 16px; margin: 8px 0 2px; }
.legend-title { font-size: 10.5px; font-weight: 700; letter-spacing: 0.8px; text-transform: uppercase; color: var(--muted); margin-bottom: 3px; }
.legend-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.legend-list li { display: flex; align-items: center; gap: 7px; min-height: 18px; line-height: 1.25; }
.legend-list canvas { flex: none; }
.legend-list .sdot { margin: 0 5px 0 4px; box-shadow: 0 0 0 1.5px #fff, 0 0 0 2.5px rgba(43, 48, 58, 0.18); }
@media (max-width: 900px) { .legend { grid-template-columns: minmax(0, 1fr); } }
/* the card folded into a button: it never disappears completely */
.help-open, .names-btn { pointer-events: auto; box-shadow: var(--shadow); }
.help-open[hidden] { display: none; }
/* «Названия» looks as «Как играть» and lights up while the names of the buildings are shown */
.names-btn.on { background: #E4ECF9; border-color: var(--blue); color: var(--blue); }
kbd {
  display: inline-block;
  min-width: 18px;
  padding: 0 4px;
  margin: 0 1px;
  font: 600 11px/16px var(--mono);
  text-align: center;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--panel-edge);
  border-bottom-width: 2px;
  border-radius: 4px;
}

/* ---------------------------------------------------------------- settings */

.settings {
  position: fixed;
  /* by the right column; on a narrow window it slides over the column rather than past the left edge (390 px wide) */
  right: clamp(8px, calc(100vw - 318px), calc(var(--side-w) + 22px));
  bottom: 76px;
  width: min(310px, calc(100vw - 16px));
  max-height: calc(100vh - 130px);
  overflow-y: auto;
  z-index: 8;
  padding: 10px 13px 12px;
  font-size: 12.5px;
}
.settings[hidden] { display: none; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 11px; }
.set-name { font-weight: 600; }
.set-note { margin: 5px 0 0; color: var(--muted); font-size: 11.5px; line-height: 1.35; }
.set-warn { color: #9B2F22; }
#set-wheel button, #set-view button, #set-quality button { font: 600 12px var(--ui); }
.settings input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--blue); }
/* «Вид»: the name over four buttons as wide as the panel */
.set-row.set-col { flex-direction: column; align-items: stretch; gap: 6px; }
#set-view button { flex: 1; padding: 5px 4px; }
/* the rows of the live scene in the plain view: pale, still clickable — the choice waits for the scene */
.set-row.set-off { opacity: 0.45; }
/* a view button that cannot work here (no WebGL, no Three.js): the note says why */
.seg button[aria-disabled="true"] { opacity: 0.4; cursor: not-allowed; }
.seg button[aria-disabled="true"].on { opacity: 1; }

.tooltip {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 10;
  pointer-events: none;
  background: rgba(33, 38, 48, 0.94);
  color: #fff;
  border-radius: 7px;
  padding: 7px 10px;
  font-size: 12px;
  max-width: 300px;
  display: none;
  box-shadow: var(--shadow);
}
.tooltip b { font-weight: 700; }
.tooltip .m { color: #B9C3D1; }
.tooltip .small { font-size: 11px; }
.tooltip .st-ok { color: #9FD8A8; }
.tooltip .st-warn { color: #F4C77A; }
.tooltip .st-bad { color: #F19A8B; }
.tooltip .st-calm { color: #C3D0E2; }
.tooltip .st-type { color: #CDB8EE; }
.tooltip .st-idle { color: #B9C3D1; }
.tooltip kbd { color: var(--text); }
/* the building tooltip: name, the state with the dot of the sprite, the reason, what to do, flows, small print */
.tip-head { margin-bottom: 1px; }
.tip-state { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; }
.tip-state .sdot { box-shadow: 0 0 0 1.5px rgba(255, 255, 255, 0.9); }
.tip-cause { margin-top: 2px; }
.tip-act { color: #FFFFFF; font-weight: 600; }
.tip-flow { color: #DCE3EC; margin-top: 3px; }
.tip-flow + .tip-flow { margin-top: 0; }
.tip-merge { color: #FFFFFF; font-weight: 600; }
/* the small print (edition, composing room, cases) keeps a little away from the flows */
.tip-flow + .small { margin-top: 3px; }
/* a tooltip that holds still: the cursor can go into it and point at a glossary word */
.tooltip.held { pointer-events: auto; box-shadow: var(--shadow), 0 0 0 2px #9DBBF0; }
/* tips over buttons and counters: at once, the cursor may go into them */
.bar-tip { pointer-events: auto; z-index: 11; }
.bar-tip.inert { pointer-events: none; }
.bar-tip div + div { margin-top: 1px; }
.term-tip { z-index: 12; max-width: 280px; background: #FBFBF7; color: var(--text); border: 1px solid var(--panel-edge); }
.term-tip b { display: block; font-family: var(--book); font-size: 14px; margin-bottom: 2px; }
/* a glossary word: dotted underline, the explanation on hover */
.term { text-decoration: underline dotted; text-decoration-thickness: 1px; text-underline-offset: 2px; cursor: help; }
.tooltip .term { text-decoration-color: rgba(255, 255, 255, 0.7); }

.toast {
  max-width: 100%;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 9px;
  box-shadow: var(--shadow);
  padding: 7px 14px;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}
.toast.show { opacity: 1; }
.toast .book-title { font-family: var(--book); font-size: 15px; font-weight: 700; }

/* ---------------------------------------------------------------- frame counter and error */

.perf {
  position: fixed;
  left: 12px;                /* under the compass */
  top: 106px;
  /* the gap left of the help card (.top-stack, .help: min(600px, 100% − 170px) wide), so the line wraps before it
     reaches the card, «Как играть» or the right column */
  max-width: calc(100vw - 304px - clamp(0px, 100vw - 466px, 600px));
  z-index: 7;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(33, 38, 48, 0.86);
  color: #D8F0DC;
  font: 500 11.5px var(--mono);
  pointer-events: none;
}
.perf[hidden] { display: none; }

/* The compass in the top left corner of the map area (0.4.0, plan 3.3): the needle shows where north is; a click turns
   north up. Only the live scene turns: the plain view hides it. */
.compass {
  position: fixed;
  left: 12px;
  top: 54px;
  z-index: 5;
  width: 44px;
  height: 44px;
  padding: 2px;
  border: 0;
  background: none;
  cursor: pointer;
  filter: drop-shadow(0 2px 5px rgba(28, 38, 56, 0.25));
}
.compass[hidden] { display: none; }
.compass svg { display: block; }
.compass-face { fill: var(--panel); stroke: var(--panel-edge); stroke-width: 1.2; }
.compass:hover .compass-face, .compass:focus-visible .compass-face { stroke: var(--blue); stroke-width: 1.8; }
.compass-n { font: 700 7.5px var(--ui); fill: var(--bad); }

.error-banner {
  position: fixed;
  left: 50%;
  top: 54px;
  transform: translateX(-50%);
  z-index: 9;
  max-width: min(640px, calc(100% - 24px));
  padding: 9px 13px;
  border-color: var(--bad);
  font-size: 12.5px;
}
.error-banner .msg { font: 500 12px var(--mono); color: #9B2F22; }
.error-banner .m { color: var(--muted); margin-top: 3px; }
.error-banner[hidden] { display: none; }

/* ---------------------------------------------------------------- narrow windows */

@media (max-width: 1180px) {
  .res--books { display: none; }
  .era-name { display: none; }
  .topbar { gap: 14px; }
}
@media (max-width: 1060px) {
  .tool { width: 40px; height: 40px; }
  .tool canvas { margin-top: 4px; }
  .tool .key.long { font-size: 8.5px; letter-spacing: -0.4px; }
  .controls { height: 46px; padding: 6px 8px; }
}

/* «Первый заказ»: what the order waits for comes first and stands out (2026-09-28). */
#stage-foot .order-need { color: #9E5F16; font-weight: 600; margin-bottom: 4px; }
#stage-foot .order-ok { color: #2C7847; font-weight: 600; margin-bottom: 4px; }
#stage-foot .order-made { margin-bottom: 4px; }
#stage-foot .order-after { color: #365FA3; font-weight: 700; margin: 10px 0 2px; }
#stage-foot .order-next { color: #365FA3; margin-bottom: 4px; }
/* A building the last order opened, until it is placed once. The badge sits over the top edge of the button, clear of
   its key: «Shift+4» takes the whole top of it on Windows. */
.tool.is-new { position: relative; box-shadow: 0 0 0 2px #E7A23B inset; }
.tool.is-new::after { content: 'новое'; position: absolute; top: -12px; right: -6px; background: #E7A23B; color: #fff; font-size: 9px; line-height: 10px; font-weight: 700; padding: 1px 4px; border-radius: 6px; }

/* ---------------------------------------------------------------- the campaign of epoch II: the board of orders (0.5.0) */

/* The board replaces the shelf of the stage panel (ui.js campaignLook): the cards of the milestones, the spines of the Bible. */
.campaign .stage { flex: none; min-height: 0; }
.board { display: flex; flex-direction: column; gap: 9px; margin-top: 7px; }
.board[hidden] { display: none; }

/* The Bible: four spines, a part handed in stands in leather, the part on the board fills from below, the rest are outlines. */
.bible-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.bible-head b { font: 700 15px/1.2 var(--book); }
.bible-head span { font: 500 11px var(--mono); color: var(--muted); }
.bible-parts { list-style: none; margin: 6px 0 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.bpart { display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 0; }
.bpart-book {
  position: relative; width: 30px; height: 40px; border-radius: 3px 3px 2px 2px;
  border: 1.5px dashed #BFA793; background: transparent;
  display: flex; align-items: center; justify-content: center;
}
.bpart-book i { position: relative; font: 700 13px var(--book); font-style: normal; color: #A58B78; }
.bpart.now .bpart-book {
  border: 1.5px solid #7A3E2B;
  background: linear-gradient(to top, #7A3E2B var(--fill), #F3E9E1 var(--fill));
}
.bpart.now .bpart-book i { color: #5A2A1C; text-shadow: 0 0 2px #fff, 0 0 4px #fff, 0 0 6px #F3E9E1; }
.bpart.done .bpart-book {
  border: 0;
  background: #7A3E2B linear-gradient(to bottom, transparent 5px, #D9B25F 5px 7px, transparent 7px calc(100% - 7px), #D9B25F calc(100% - 7px) calc(100% - 5px), transparent calc(100% - 5px));
  box-shadow: inset 2px 0 0 rgba(0, 0, 0, 0.18), 0 1px 2px rgba(28, 38, 56, 0.25);
}
.bpart.done .bpart-book i { color: #F0D38A; }
.bpart-name { font-size: 10.5px; line-height: 1.2; text-align: center; color: var(--muted); text-wrap: balance; }
.bpart.now .bpart-name { color: var(--text); font-weight: 600; }

/* A card of a milestone. A part of the Bible has the leather of the Bible on its left edge. */
.card { position: relative; border: 1px solid var(--panel-edge); border-radius: 8px; padding: 7px 10px 9px; background: #fff; cursor: pointer; }
.card:hover { border-color: #9FB0C6; }
.card.part { border-left: 3px solid #7A3E2B; padding-left: 8px; }
.card-top { display: flex; align-items: baseline; gap: 6px; }
.card-kicker { flex: 1; min-width: 0; font-size: 10px; font-weight: 700; letter-spacing: 0.8px; text-transform: uppercase; color: var(--muted); }
.card .count { font: 700 14px var(--mono); white-space: nowrap; }
.card .tag { font-size: 10px; font-weight: 700; letter-spacing: 0.4px; text-transform: uppercase; border-radius: 4px; padding: 1px 5px; }
.card .tag.next { background: #fff; color: var(--type); box-shadow: inset 0 0 0 1px var(--type); }
.card-title { margin: 1px 0 0; font: 700 17px/1.2 var(--book); }
.props { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 0; margin-top: 3px; font-size: 11.5px; letter-spacing: -0.1px; }
.prop { display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; }
/* the dot ends a property, so that a line that wraps never begins with it */
.prop:not(:last-child)::after { content: '·'; color: var(--faint); margin: 0 4px 0 3px; }
.card .progress { height: 5px; margin: 6px 0 7px; }
.card-wait { font-weight: 600; line-height: 1.3; padding-left: 8px; border-left: 3px solid var(--calm); }
.card-wait.st-ok { border-color: var(--ok); }
.card-wait.st-warn { border-color: var(--warn); }
.card-wait.st-bad { border-color: var(--bad); color: #9B2F22; }
.card-wait.st-type { border-color: var(--type); }
.card-wait.st-idle { border-color: var(--idle); }
.card-act { margin-top: 2px; padding-left: 11px; line-height: 1.3; }
.card-now { margin-top: 2px; padding-left: 11px; line-height: 1.3; font-size: 11.5px; color: var(--muted); }
.card-line { margin-top: 6px; font-size: 12px; line-height: 1.35; }

/* What comes once the board is in: one line under the cards, with the words of its time in bold. */
.board-next { padding: 0 2px; font-size: 12px; line-height: 1.35; color: #365FA3; }

/* The icons of the properties: a sheet, a soft cover, a hard book in leather, a stack of copies. */
.ico { display: inline-block; flex: none; box-sizing: border-box; }
.ico-sheets { width: 10px; height: 13px; background: #fff; border: 1px solid #8C97A8; border-radius: 1px; box-shadow: inset 0 -3px 0 -2px #C9D0DA, inset 0 -6px 0 -5px #C9D0DA; }
.ico-soft { width: 11px; height: 13px; background: #EFE5CC; border: 1px solid #B9A67E; border-left-width: 2px; border-radius: 1px 2px 2px 1px; }
.ico-hard { width: 12px; height: 14px; border-radius: 1px 3px 3px 1px; background: #7A3E2B linear-gradient(to bottom, transparent 3px, #D9B25F 3px 4px, transparent 4px 10px, #D9B25F 10px 11px, transparent 11px); box-shadow: inset 2px 0 0 #54261A; }
.ico-copies { width: 13px; height: 12px; background: linear-gradient(to bottom, #A8433A 0 3px, transparent 3px 4.5px, #2F4A7A 4.5px 7.5px, transparent 7.5px 9px, #C8963E 9px 12px); border-radius: 1px; }
.ico-pen { width: 12px; height: 12px; background: linear-gradient(135deg, transparent 45%, #3A3F4A 45% 55%, transparent 55%); }

/* The epoch is over: the line of it at the bottom of the board. */
.epoch-end { border-top: 1px solid var(--panel-edge); padding-top: 8px; }
.epoch-end .colophon { margin-top: 4px; }
.epoch-next { margin-top: 6px; font-size: 12px; line-height: 1.35; color: var(--muted); }

/* The message of a handed-in milestone over the toolbar, where the new buttons light up: what it opened, «Показать» takes
   the camera to the new plot. Clear of the pause notice and of the card «Как играть» at the top of the map. */
.news { display: flex; align-items: center; gap: 10px; max-width: min(640px, 100%); padding: 8px 10px 8px 12px; pointer-events: auto; border-left: 4px solid var(--ok); }
.news[hidden] { display: none; }
.news-text { flex: 1; min-width: 0; font-weight: 600; line-height: 1.35; }
.news .btn, .news .link { flex: none; }
.news .btn[hidden] { display: none; }

/* «Эпоха II пройдена» over the map, in the middle of its free part. */
.epoch-done {
  position: fixed;
  left: calc((100vw - var(--side-w) - 22px) / 2);
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 9;
  width: min(500px, calc(100vw - var(--side-w) - 60px));
  max-height: calc(100vh - 140px);
  overflow-y: auto;
  padding: 16px 22px 18px;
  text-align: center;
}
.epoch-done[hidden] { display: none; }
.epoch-done h2 { margin: 3px 0 4px; font: 700 26px/1.2 var(--book); }
.epoch-done .bible-parts { max-width: 280px; margin: 10px auto 12px; }
.epoch-done .colophon { margin: 0; font-size: 15px; }
.epoch-done .epoch-next { margin: 10px 0 14px; }

/* A short window (1024×680): the board keeps its lines, a little tighter, so that two cards and the Bible fit in the column. */
@media (max-height: 760px) {
  .board { gap: 7px; margin-top: 5px; }
  .bible-parts { margin-top: 4px; }
  .bpart-book { width: 26px; height: 32px; }
  .bpart-book i { font-size: 12px; }
  .bpart-name { font-size: 10px; }
  .card { padding: 6px 9px 7px; }
  .card.part { padding-left: 7px; }
  .card-title { font-size: 15.5px; }
  .card .progress { margin: 5px 0 6px; }
  .card-line { margin-top: 4px; font-size: 11.5px; line-height: 1.3; }
  .card-act, .card-now { font-size: 11.5px; }
}
