/* Деревня за рубль.
   Раскладка: шапка с разделами; в игре слева деревня и сводка, справа — дела недели. На телефоне всё в одну колонку, кнопка хода внизу.
   Цвета взяты из сериала: ночное небо, жёлтый свет окон, зелёные крыши, красная плашка срока. */
:root {
  --bg: #eef1f6;
  --surface: #ffffff;
  --surface-2: #f4f6fa;
  --line: #dde3ec;
  --ink: #18223a;
  --muted: #5d6a83;
  --window: #f2c14e;
  --window-ink: #8a6200;
  --on-window: #2a1f00;
  --roof: #2f8f5b;
  --deadline: #d6454b;
  --night: #101a2e;
  --paper: #fbf7ea;
  --paper-line: #d7deea;
  --paper-margin: #e3a0a0;
  --shadow: 0 1px 2px rgba(24, 34, 58, .06), 0 4px 16px rgba(24, 34, 58, .06);
  --font-text: "Golos Text", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --font-display: "Unbounded", "Golos Text", -apple-system, "Segoe UI", Arial, sans-serif;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c1322; --surface: #141d31; --surface-2: #1a2540; --line: #26324d; --ink: #e9edf5; --muted: #95a2bb;
    --window: #f2c14e; --window-ink: #f2c14e; --on-window: #2a1f00; --roof: #4fbf82; --deadline: #ff6b70; --night: #0b1222;
    --paper: #f3eedd; --paper-line: #cfd8e6; --paper-margin: #e08b8b; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0c1322; --surface: #141d31; --surface-2: #1a2540; --line: #26324d; --ink: #e9edf5; --muted: #95a2bb;
  --window: #f2c14e; --window-ink: #f2c14e; --on-window: #2a1f00; --roof: #4fbf82; --deadline: #ff6b70; --night: #0b1222;
  --paper: #f3eedd; --paper-line: #cfd8e6; --paper-margin: #e08b8b; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.45 var(--font-text); -webkit-font-smoothing: antialiased; overflow-x: hidden; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--window); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }
h1, h2, h3 { text-wrap: balance; margin: 0; }

/* ---------- шапка ---------- */
.top { position: sticky; top: 0; z-index: 20; background: var(--night); color: #e9edf5; }
.top-in { max-width: 1180px; margin: 0 auto; display: flex; align-items: center; gap: 18px; padding-block: 10px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-family: var(--font-display); font-weight: 700; font-size: 15px; letter-spacing: -.01em; white-space: nowrap; }
.brand .coin { width: 28px; height: 28px; border-radius: 50%; background: var(--window); color: var(--on-window); display: grid; place-items: center; font-size: 13px; font-weight: 800; }
.nav { display: flex; gap: 4px; margin-left: auto; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a { text-decoration: none; padding: 7px 12px; border-radius: 9px; color: #b9c3d6; font-weight: 600; font-size: 14px; white-space: nowrap; }
.nav a:hover { color: #fff; background: rgba(255,255,255,.06); }
.nav a.on { color: var(--night); background: #e9edf5; }
@media (max-width: 560px) { .brand .word { display: none; } .nav { margin-left: 0; } .top-in { gap: 10px; } }

.wrap { max-width: 1180px; margin: 0 auto; padding-block: 20px 120px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }

/* ---------- общее ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.pad { padding: 16px; }
.label { font-size: 11.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 11px; padding: 11px 18px; font-weight: 700; background: var(--surface-2); border: 1px solid var(--line); transition: transform .08s ease; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--window); color: var(--on-window); border-color: transparent; }
.btn.go { background: var(--roof); color: #fff; border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--deadline); }
.btn[disabled] { opacity: .5; cursor: default; }
.btn.wide { width: 100%; }
.field { display: grid; gap: 6px; }
.input { width: 100%; padding: 12px 14px; border-radius: 11px; border: 1px solid var(--line); background: var(--surface-2); outline: none; }
.input:focus { border-color: var(--window); }
.err { color: var(--deadline); font-size: 13.5px; min-height: 1.2em; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; }
.seg button { padding: 7px 12px; border-radius: 9px; font-weight: 600; font-size: 14px; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip { padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); font-weight: 600; font-size: 13.5px; white-space: nowrap; }
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip .n { opacity: .6; margin-left: 4px; font-weight: 500; }

/* ---------- стартовый экран ---------- */
.hero { position: relative; overflow: hidden; border-radius: 20px; background: var(--night); color: #e9edf5; }
.hero .scene svg { height: 230px; }
.hero-text { padding: 22px 22px 24px; display: grid; gap: 14px; max-width: 640px; }
.hero h1 { font-family: var(--font-display); font-size: clamp(30px, 6vw, 52px); line-height: 1.02; letter-spacing: -.02em; font-weight: 800; }
.hero h1 em { font-style: normal; color: var(--window); }
.hero p { margin: 0; color: #c1cadb; font-size: 16px; max-width: 58ch; }
.start-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 16px; margin-top: 16px; }
@media (max-width: 860px) { .start-grid { grid-template-columns: 1fr; } }
.rules { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.rules li { display: grid; grid-template-columns: 28px 1fr; gap: 10px; align-items: start; }
.rules b.k { width: 28px; height: 28px; border-radius: 8px; background: var(--surface-2); display: grid; place-items: center; font-family: var(--font-display); font-size: 12px; }
.stack { display: grid; gap: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }

/* ---------- игра ---------- */
.hud { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stat { border-radius: 12px; border: 2px solid; padding: 7px 8px 8px; text-align: center; background: var(--surface); min-width: 0; }
.stat small { display: block; font-size: 10.5px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.stat b { font-family: var(--font-display); font-size: clamp(14px, 2.4vw, 19px); font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.stat.d { border-color: var(--deadline); color: var(--deadline); }
.stat.p { border-color: var(--roof); color: var(--roof); }
.stat.m { border-color: var(--window); color: var(--window-ink); }
.scene { overflow-x: auto; overflow-y: hidden; scrollbar-width: none; background: var(--night); min-width: 0; max-width: 100%; }
.scene::-webkit-scrollbar { display: none; }
.scene svg { display: block; height: 220px; width: auto; }
.game .scene { border-radius: var(--radius); margin-top: 10px; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; padding: 10px 2px; font-size: 13.5px; color: var(--muted); }
.meta b { color: var(--ink); font-variant-numeric: tabular-nums; }
.meta .good { color: var(--roof); } .meta .bad { color: var(--deadline); }
.dots { display: inline-flex; gap: 5px; align-items: center; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--window); }
.dot.off { background: var(--line); }
.sync { margin-left: auto; font-size: 12.5px; }
.sync.warn { color: var(--deadline); }

.game { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 420px); gap: 20px; align-items: start; }
.side { position: sticky; top: 70px; display: grid; gap: 10px; max-height: calc(100vh - 86px); grid-template-rows: auto auto minmax(0, 1fr) auto; }
.side .list { overflow-y: auto; display: grid; gap: 8px; align-content: start; padding-right: 2px; }
.tabs-mobile { display: none; }
@media (max-width: 980px) {
  .game { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; max-height: none; grid-template-rows: none; }
  .side .list { overflow: visible; }
  .tabs-mobile { display: flex; }
  .game.t-info .side { display: none; }
  .game.t-acts .info { display: none; }
  .next-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; padding: 12px max(16px, env(safe-area-inset-right, 0px)) calc(12px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); background: linear-gradient(transparent, var(--bg) 35%); }
}
.info { display: grid; gap: 12px; min-width: 0; }
.panel { padding: 14px 16px; }
.panel h3 { font-size: 12px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); margin: 4px 0 8px; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.kv:last-child { border-bottom: 0; }
.kv span:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.plus { color: var(--roof); } .minus { color: var(--deadline); }

.act { padding: 12px 14px; display: grid; gap: 6px; }
.act h4 { margin: 0; font-size: 15px; }
.act p { margin: 0; color: var(--muted); font-size: 13.5px; }
.act .foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 4px; }
.price { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--window-ink); }
.price small { color: var(--muted); font-weight: 500; }
.why { font-size: 12.5px; color: var(--muted); text-align: right; }
.act .btn { padding: 8px 14px; }
.act.locked { background: var(--surface-2); }
.building { padding: 10px 14px; display: grid; gap: 6px; }
.bar { height: 5px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--roof); }
.done-list { padding: 10px 14px; display: flex; flex-wrap: wrap; gap: 6px; }
.done-list span { font-size: 12.5px; padding: 4px 8px; border-radius: 7px; background: var(--surface-2); color: var(--muted); }

/* тетрадка Нины */
.note { background: var(--paper); color: #2b261c; border-radius: 6px; position: relative; padding: 10px 14px 10px 40px;
  background-image: repeating-linear-gradient(var(--paper) 0 27px, var(--paper-line) 27px 28px); font-weight: 600; box-shadow: var(--shadow); }
.note::before { content: ""; position: absolute; left: 28px; top: 0; bottom: 0; width: 2px; background: var(--paper-margin); }
.note .t { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; line-height: 28px; color: #6b6253; }
.note div.i { line-height: 28px; display: flex; justify-content: space-between; }
.note .ok { color: #1f8d55; } .note .no { color: #b7b09e; }
.quote { font-size: 15px; margin: 0; }
.quote::before { content: "«"; } .quote::after { content: "»"; }

.log-list { display: grid; }
.log-list div { padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.log-list div:last-child { border: 0; }
.log-list small { display: block; color: var(--muted); font-size: 12px; }

/* ---------- окно событий ---------- */
.modal { position: fixed; inset: 0; z-index: 40; background: rgba(6, 10, 20, .62); display: flex; align-items: center; justify-content: center; padding: 16px; }
.sheet { background: var(--surface); color: var(--ink); width: 100%; max-width: 520px; max-height: calc(100vh - 32px); overflow: auto; border-radius: 18px; padding: 20px; box-shadow: 0 20px 60px rgba(0,0,0,.35); animation: rise .18s ease-out; }
@media (max-width: 600px) { .modal { align-items: flex-end; padding: 0; } .sheet { border-radius: 18px 18px 0 0; max-height: 92vh; padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px)); } }
@keyframes rise { from { transform: translateY(12px); opacity: .6; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .sheet { animation: none; } }
.sheet h2 { font-size: 21px; margin: 6px 0 10px; }
.sheet p { margin: 0 0 12px; white-space: pre-line; }
.tag { display: inline-block; font-size: 11px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; padding: 4px 9px; border-radius: 7px; background: var(--surface-2); color: var(--window-ink); }
.tag.win { background: var(--roof); color: #fff; } .tag.lose { background: var(--deadline); color: #fff; }
.opt { display: block; width: 100%; text-align: left; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); font-weight: 600; margin-top: 8px; }
.opt:hover:not([disabled]) { border-color: var(--window); }
.opt small { display: block; font-weight: 400; color: var(--muted); margin-top: 2px; }
.opt[disabled] { opacity: .55; cursor: default; }
.result-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 14px 0; }
.result-grid div { background: var(--surface-2); border-radius: 10px; padding: 10px; }
.result-grid b { display: block; font-family: var(--font-display); font-size: 18px; font-variant-numeric: tabular-nums; }
.result-grid small { color: var(--muted); font-size: 12px; }
.banner { padding: 10px 12px; border-radius: 10px; background: var(--surface-2); font-size: 14px; margin-bottom: 10px; }
.banner b { color: var(--window-ink); }

/* ---------- рейтинг ---------- */
.page-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { font-family: var(--font-display); font-size: clamp(24px, 4vw, 34px); letter-spacing: -.02em; }
.cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 340px); gap: 20px; align-items: start; }
@media (max-width: 900px) { .cols { grid-template-columns: minmax(0, 1fr); } }
.table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.table th { text-align: left; font-size: 11.5px; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); font-weight: 700; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table td.r, .table th.r { text-align: right; font-variant-numeric: tabular-nums; }
.table tr.me td { background: color-mix(in srgb, var(--window) 14%, transparent); }
.table a { text-decoration: none; font-weight: 700; }
.table a:hover { text-decoration: underline; }
.place { width: 30px; height: 30px; border-radius: 9px; display: inline-grid; place-items: center; font-weight: 800; font-size: 13px; background: var(--surface-2); font-variant-numeric: tabular-nums; }
.place.g1 { background: var(--window); color: var(--on-window); } .place.g2 { background: #c9d1de; color: #1b2438; } .place.g3 { background: #d9a173; color: #2b1a0b; }
.end-pill { display: inline-block; font-size: 12.5px; padding: 3px 8px; border-radius: 7px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.end-pill.w { color: var(--roof); }
.hide-sm { }
@media (max-width: 640px) { .hide-sm { display: none; } .table td, .table th { padding: 10px 8px; } }
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.tile { background: var(--surface-2); border-radius: 12px; padding: 12px; }
.tile b { display: block; font-family: var(--font-display); font-size: 22px; font-variant-numeric: tabular-nums; }
.tile small { color: var(--muted); font-size: 12.5px; }
.feed div { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.feed div:last-child { border: 0; }
.feed small { color: var(--muted); grid-column: 1 / -1; font-size: 12.5px; }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); }
.table-wrap { overflow-x: auto; }

/* ---------- концовки ---------- */
.ends { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.end { padding: 14px; display: grid; gap: 6px; align-content: start; min-height: 128px; }
.end h4 { margin: 0; font-size: 15px; }
.end p { margin: 0; font-size: 13.5px; color: var(--muted); }
.end .foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.end.locked { background: var(--surface-2); border-style: dashed; }
.end.locked h4 { color: var(--muted); }
.kind { font-size: 11px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; }
.kind.w { color: var(--roof); } .kind.l { color: var(--deadline); } .kind.e { color: var(--window-ink); }
.progress { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--window); }

/* ---------- профиль ---------- */
.profile-head { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.avatar { width: 64px; height: 64px; border-radius: 18px; background: var(--window); color: var(--on-window); display: grid; place-items: center; font-family: var(--font-display); font-weight: 800; font-size: 26px; }
.key { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); word-break: break-all; user-select: all; }

.toast { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 11px; font-weight: 600; z-index: 60; box-shadow: var(--shadow); max-width: calc(100% - 32px); }
.foot-note { margin-top: 28px; font-size: 12.5px; color: var(--muted); text-align: center; }

/* ---------- раскладка игры по областям ---------- */
.game { grid-template-areas: "board side" "info side"; }
.board { grid-area: board; min-width: 0; }
.game .info { grid-area: info; }
.game .side { grid-area: side; grid-row: 1 / span 2; }
@media (max-width: 980px) { .game { grid-template-areas: "board" "info" "side"; } .game .side { grid-row: auto; } }

/* ---------- жизнь в сцене ---------- */
.sv .smoke { opacity: .22; animation: smoke 4.5s ease-out infinite both; transform-box: fill-box; transform-origin: center; }
@keyframes smoke { 0% { transform: translate(0, 0) scale(.5); opacity: 0; } 25% { opacity: .45; } 100% { transform: translate(7px, -26px) scale(1.7); opacity: 0; } }
.sv .star { animation: twinkle 3.2s ease-in-out infinite; }
@keyframes twinkle { 50% { opacity: .12; } }
.sv .snow { animation: fall linear infinite; }
@keyframes fall { from { transform: translateY(-260px); } to { transform: translateY(260px); } }
.sv .glow { animation: glow 3.6s ease-in-out infinite; }
@keyframes glow { 50% { opacity: .05; } }
.sv .cow { animation: graze 5s ease-in-out infinite; transform-box: fill-box; }
@keyframes graze { 50% { transform: translateX(3px); } }

/* ---------- главное меню ---------- */
.menu { position: relative; overflow: hidden; border-radius: 22px; background: var(--night); color: #e9edf5; min-height: max(560px, min(780px, calc(100vh - 100px))); display: grid; grid-template-columns: minmax(0, 1fr); align-content: start; isolation: isolate; }
.menu .bg { position: absolute; inset: 0; z-index: -1; overflow: hidden; display: flex; align-items: flex-end; background: linear-gradient(#0e1730, #0e1730); }
.menu .bg svg { height: 82%; flex: none; width: auto; display: block; transform: translateX(-30%); animation: pan 70s ease-in-out infinite alternate; }
@keyframes pan { from { transform: translateX(-26%); } to { transform: translateX(-58%); } }
.menu .bg::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(11,18,34,.7) 0%, rgba(11,18,34,.25) 40%, rgba(11,18,34,0) 62%); }
.menu-in { padding: clamp(26px, 5vw, 56px) clamp(18px, 4vw, 48px) 32px; display: grid; gap: 22px; grid-template-columns: minmax(0, 1fr) minmax(0, 360px); align-items: start; }
@media (max-width: 860px) { .menu-in { grid-template-columns: minmax(0, 1fr); } .menu { min-height: calc(100vh - 90px); } .menu .bg::after { background: linear-gradient(180deg, rgba(11,18,34,.75) 0%, rgba(11,18,34,.55) 60%, rgba(11,18,34,.1) 85%); } }
.menu .eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--window); animation: up .7s .2s cubic-bezier(.2,.7,.2,1) both; }
.menu h1 { font-family: var(--font-display); font-weight: 800; font-size: clamp(38px, 7.4vw, 86px); line-height: .98; letter-spacing: -.03em; margin-top: 10px; }
.menu h1 .w { display: inline-block; white-space: nowrap; }
.menu h1 .ch { display: inline-block; animation: letter .7s cubic-bezier(.2,.7,.2,1) both; }
.menu h1 .gold { color: var(--window); }
@keyframes letter { from { opacity: 0; transform: translateY(.45em) rotate(4deg); filter: blur(6px); } to { opacity: 1; transform: none; filter: none; } }
.menu .lede { margin: 14px 0 0; color: #c1cadb; font-size: 16.5px; max-width: 52ch; animation: up .8s 1.3s cubic-bezier(.2,.7,.2,1) both; }
@keyframes up { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.menu-list { display: grid; gap: 8px; }
.menu-list > * { animation: up .6s cubic-bezier(.2,.7,.2,1) both; }
.mbtn { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; padding: 14px 18px; border-radius: 14px; background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.12); color: #e9edf5; font-weight: 700; font-size: 16px; text-align: left; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); transition: background .2s, transform .2s, border-color .2s; text-decoration: none; }
.mbtn:hover { background: rgba(255,255,255,.13); transform: translateX(3px); }
.mbtn small { display: block; font-weight: 500; font-size: 13px; color: #aab5ca; margin-top: 2px; }
.mbtn .arr { opacity: .55; transition: transform .2s; }
.mbtn:hover .arr { transform: translateX(3px); opacity: 1; }
.mbtn.primary { background: var(--window); color: var(--on-window); border-color: transparent; }
.mbtn.primary small { color: #5b4507; }
.menu .who { font-size: 13.5px; color: #aab5ca; animation: up .6s 1.9s both; }
.menu .who b { color: #e9edf5; }

/* ---------- кино: заставка и финал ---------- */
.cine { position: fixed; inset: 0; z-index: 70; background: #05080f; color: #f1f4fa; overflow: hidden; }
.cine .cam { position: absolute; inset: 0; display: grid; place-items: center; }
.cine .cam svg { height: 100%; width: auto; max-width: none; transform-origin: 36% 82%; transition: transform 5.5s cubic-bezier(.45,.05,.25,1), filter 2s; }
.cine .bars::before, .cine .bars::after { content: ""; position: fixed; left: 0; right: 0; height: 12vh; background: #000; z-index: 2; animation: bar 1.2s cubic-bezier(.6,0,.2,1) both; }
.cine .bars::before { top: 0; } .cine .bars::after { bottom: 0; transform-origin: bottom; }
@keyframes bar { from { transform: scaleY(0); } to { transform: scaleY(1); } }
.cine .bars::before { transform-origin: top; }
.cine .cap { position: absolute; left: 0; right: 0; bottom: calc(12vh + 28px); z-index: 3; text-align: center; padding: 0 24px; font-family: var(--font-display); font-weight: 700; font-size: clamp(20px, 3.6vw, 40px); line-height: 1.15; letter-spacing: -.01em; text-shadow: 0 2px 24px rgba(0,0,0,.6); text-wrap: balance; }
.cine .cap span { display: inline-block; animation: capin .9s cubic-bezier(.2,.7,.2,1) both; }
.cine .cap .hl { color: var(--window); }
.cine .cap .red { color: #ff6b70; }
@keyframes capin { from { opacity: 0; transform: translateY(12px); filter: blur(8px); } to { opacity: 1; transform: none; filter: none; } }
.cine .cap.out span { animation: capout .5s ease-in both; }
@keyframes capout { to { opacity: 0; transform: translateY(-8px); filter: blur(6px); } }
.cine .skip { position: absolute; z-index: 4; right: max(16px, env(safe-area-inset-right, 0px)); top: calc(12vh + 14px); padding: 8px 14px; border-radius: 10px; background: rgba(255,255,255,.12); color: #e9edf5; font-weight: 600; font-size: 14px; }
.cine .shade { position: absolute; inset: 0; background: radial-gradient(ellipse at center, rgba(5,8,15,0) 30%, rgba(5,8,15,.75) 100%); z-index: 1; pointer-events: none; }
.cine.fin .cam svg { filter: brightness(.55) saturate(.9); }
.cine .fin-body { position: absolute; inset: 12vh 0; z-index: 3; overflow-y: auto; display: grid; place-items: center; padding: 20px max(16px, env(safe-area-inset-right, 0px)) 20px max(16px, env(safe-area-inset-left, 0px)); }
.fin-card { width: 100%; max-width: 620px; display: grid; gap: 14px; text-align: center; }
.fin-card > * { animation: up .9s cubic-bezier(.2,.7,.2,1) both; }
.fin-card h2 { font-family: var(--font-display); font-size: clamp(30px, 6vw, 58px); line-height: 1; letter-spacing: -.03em; text-wrap: balance; }
.fin-card p { margin: 0 auto; max-width: 52ch; color: #d1d8e6; font-size: 16.5px; }
.fin-card .epi { color: #b9c3d6; font-size: 15px; }
.fin-card .tag { justify-self: center; }
.fin-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
@media (max-width: 560px) { .fin-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.fin-stats div { background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.1); border-radius: 12px; padding: 12px 8px; }
.fin-stats b { display: block; font-family: var(--font-display); font-size: 24px; font-variant-numeric: tabular-nums; }
.fin-stats small { color: #aab5ca; font-size: 12.5px; }
.fin-note { padding: 12px 14px; border-radius: 12px; background: rgba(242,193,78,.12); border: 1px solid rgba(242,193,78,.3); color: #f6e2ae; font-size: 14.5px; }
.fin-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.fin-actions .btn { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.14); color: #e9edf5; }
.fin-actions .btn.primary { background: var(--window); color: var(--on-window); }

/* ---------- титр недели и анимации интерфейса ---------- */
.weekcard { position: fixed; left: 50%; top: 76px; z-index: 30; transform: translateX(-50%); background: var(--night); color: #e9edf5; padding: 10px 20px 11px; border-radius: 14px; text-align: center; box-shadow: 0 12px 40px rgba(0,0,0,.3); animation: wk 1.9s cubic-bezier(.2,.7,.2,1) both; pointer-events: none; }
.weekcard b { display: block; font-family: var(--font-display); font-size: 20px; }
.weekcard small { color: #aab5ca; font-size: 12.5px; }
@keyframes wk { 0% { opacity: 0; transform: translate(-50%, -14px); } 15%, 75% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; transform: translate(-50%, -8px); } }
.stat.bump { animation: bump .6s cubic-bezier(.2,.7,.2,1); }
@keyframes bump { 30% { transform: scale(1.06); } }
.view-in { animation: viewIn .45s cubic-bezier(.2,.7,.2,1); }
@keyframes viewIn { from { opacity: 0; transform: translateY(14px); } }
.sheet .opt { animation: up .4s cubic-bezier(.2,.7,.2,1) both; }
.act { transition: border-color .15s, transform .15s; }
.act:hover { border-color: color-mix(in srgb, var(--window) 55%, var(--line)); }
.list .act { animation: up .35s cubic-bezier(.2,.7,.2,1) both; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

.desk-only { }
@media (max-width: 980px) { .desk-only { display: none !important; } }

/* ---------- живая сцена ---------- */
.scene-wrap { position: relative; margin-top: 10px; border-radius: var(--radius); overflow: hidden; background: var(--night); }
.game .scene-wrap .scene { margin-top: 0; border-radius: 0; }
.game .scene svg { height: clamp(200px, 30vh, 330px); }
.scene-ui { position: absolute; top: 10px; right: 10px; display: flex; gap: 6px; z-index: 2; }
.sbtn { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: rgba(10, 16, 30, .62); color: #e9edf5; border: 1px solid rgba(255,255,255,.14); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.sbtn:hover { background: rgba(10, 16, 30, .8); }
.reveal { position: absolute; left: 50%; top: 14px; transform: translateX(-50%); z-index: 2; pointer-events: none; max-width: calc(100% - 120px); }
.reveal span { display: inline-block; padding: 8px 16px; border-radius: 12px; background: rgba(10, 16, 30, .78); color: #f6e2ae; font-weight: 700; font-size: 14.5px; border: 1px solid rgba(242,193,78,.35); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.reveal.go span { animation: revealIn 2.3s cubic-bezier(.2,.7,.2,1) both; }
@keyframes revealIn { 0% { opacity: 0; transform: translateY(-10px) scale(.96); } 12%, 82% { opacity: 1; transform: none; } 100% { opacity: 0; transform: translateY(-6px); } }
.theater-bar { display: none; }
.sv .ft.born { animation: born 1.2s cubic-bezier(.2,.8,.2,1) both; transform-box: fill-box; transform-origin: 50% 100%; }
@keyframes born { 0% { transform: translateY(16px) scaleY(.05); opacity: 0; } 55% { transform: scaleY(1.08); opacity: 1; } 75% { transform: scaleY(.97); } 100% { transform: none; } }
.sv .ft.flash { animation: flash 1.6s ease-out both; }
@keyframes flash { 0% { filter: brightness(3.2) drop-shadow(0 0 10px #ffd76a); } 100% { filter: none; } }
.sv .ft.born .lampbulb { animation: lampOn .9s calc(var(--i) * .12s) both; }
@keyframes lampOn { 0% { opacity: 0; } 35% { opacity: 1; } 50% { opacity: .2; } 70%, 100% { opacity: 1; } }
.sv .dust { animation: dust 1.3s ease-out both; }
@keyframes dust { from { transform: translate(0, 0); opacity: .95; } to { transform: translate(var(--dx), var(--dy)); opacity: 0; } }
.sv .beam { animation: beam 2.1s ease-out both; }
@keyframes beam { 0% { opacity: 0; } 20% { opacity: 1; } 100% { opacity: 0; } }
.sv .blink { animation: blinkA 1.4s steps(2, end) infinite; }
@keyframes blinkA { 50% { opacity: .15; } }
.sv .crane .jib { animation: jib 6s ease-in-out infinite alternate; }
@keyframes jib { from { transform: rotate(-4deg); } to { transform: rotate(5deg); } }
.sv .flow { animation: flow 1.2s linear infinite; }
@keyframes flow { to { stroke-dashoffset: -18; } }
.sv .pulse { animation: twinkle 1.6s ease-in-out infinite; }
.sv .screen { animation: glow 4s ease-in-out infinite; }
.sv .swing { animation: swing 2.4s ease-in-out infinite alternate; transform-box: view-box; }
@keyframes swing { from { transform: rotate(-16deg); } to { transform: rotate(16deg); } }
.sv .boat { animation: graze 6s ease-in-out infinite; transform-box: fill-box; }

/* ---------- режим кино ---------- */
body.no-scroll { overflow: hidden; }
.game.theater .board { position: fixed; inset: 0; z-index: 25; background: #05080f; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px)) calc(10px + env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px)); }
.game.theater .board .tabs-mobile { display: none; }
.game.theater .scene-wrap { margin: 0; min-height: 0; display: grid; }
.game.theater .scene { height: 100%; }
.game.theater .scene svg { height: 100%; }
.game.theater .theater-bar { display: flex; justify-content: center; position: absolute; left: 0; right: 0; bottom: 14px; z-index: 2; pointer-events: none; }
.game.theater .theater-bar .btn { pointer-events: auto; box-shadow: 0 10px 30px rgba(0,0,0,.4); padding: 12px 22px; }
.game.theater .meta { color: #aab5ca; } .game.theater .meta b { color: #e9edf5; }
.game.theater .stat { background: rgba(255,255,255,.04); }

/* ---------- заставка: кнопки ---------- */
.cine .cine-btns { position: absolute; z-index: 4; right: max(16px, env(safe-area-inset-right, 0px)); top: calc(12vh + 14px); display: flex; gap: 8px; }
.cine .cine-btns .skip { position: static; }

/* ---------- телефон ---------- */
@media (max-width: 600px) {
  .wrap { padding-block: 12px 110px; }
  .hud { gap: 6px; }
  .stat { padding: 6px 4px 7px; border-radius: 10px; }
  .stat small { font-size: 9.5px; letter-spacing: .04em; }
  .stat b { font-size: 15px; }
  .game .scene svg { height: 210px; }
  .meta { font-size: 12.5px; gap: 4px 12px; }
  .sync { margin-left: 0; }
  .act .btn { padding: 10px 16px; }
  .chip { padding: 9px 13px; }
  .reveal span { font-size: 13px; padding: 7px 12px; }
  .menu h1 { font-size: clamp(34px, 11vw, 48px); }
  .mbtn { padding: 13px 16px; }
  .cine .cap { font-size: clamp(18px, 5.4vw, 26px); }
  .fin-card h2 { font-size: clamp(28px, 9vw, 40px); }
  .page-head .seg { width: 100%; }
  .page-head .seg button { flex: 1; }
  .top-in { padding-block: 8px; }
  .nav a { padding: 7px 9px; font-size: 13.5px; }
}
@media (orientation: landscape) and (max-height: 500px) {
  .game .scene svg { height: 62vh; }
  .menu { min-height: 100vh; }
}

/* ---------- в игре всё помещается в экран: страница не прокручивается, листаются только панели ---------- */
body.in-game { height: 100vh; height: 100dvh; overflow: hidden; display: flex; flex-direction: column; }
body.in-game .top { position: static; flex: none; }
body.in-game > .wrap { flex: 1; min-height: 0; width: 100%; padding-block: 12px; display: flex; flex-direction: column; }
body.in-game .game { flex: 1; min-height: 0; grid-template-rows: auto minmax(0, 1fr); align-items: stretch; }
body.in-game .game > * { min-width: 0; }
body.in-game .game .info { min-height: 0; overflow-y: auto; align-content: start; overscroll-behavior: contain; padding-right: 4px; }
body.in-game .side { position: static; max-height: none; height: 100%; min-height: 0; grid-template-rows: auto auto minmax(0, 1fr) auto; }
body.in-game .side .list { overflow-y: auto; overscroll-behavior: contain; }
body.in-game .game .scene svg { height: clamp(160px, 30vh, 340px); height: clamp(160px, 30dvh, 340px); }
@media (max-width: 980px) {
  body.in-game > .wrap { padding-block: 8px 0; }
  body.in-game .game { display: flex; flex-direction: column; gap: 8px; }
  body.in-game .board { flex: none; }
  body.in-game .board .meta { padding: 6px 2px 4px; }
  body.in-game .game .scene svg { height: clamp(120px, 24vh, 230px); height: clamp(120px, 24dvh, 230px); }
  body.in-game .game.t-acts .side { flex: 1; min-height: 0; display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; gap: 8px; }
  body.in-game .game.t-info .info { flex: 1; min-height: 0; display: grid; }
  body.in-game .game.t-info .side { display: block; flex: none; height: auto; } /* иначе height:100% забирает всю высоту и вкладка «Тетрадка/Люди/Деньги» схлопывается в 0 */
  body.in-game .game.t-info .side > :not(.next-bar) { display: none; }
  body.in-game .next-bar { position: static; padding: 6px 0 calc(8px + env(safe-area-inset-bottom, 0px)); background: none; }
  body.in-game .toast { bottom: calc(80px + env(safe-area-inset-bottom, 0px)); }
}
@media (max-height: 620px) and (max-width: 980px) {
  body.in-game .stat { padding: 3px 4px; }
  body.in-game .stat small { display: none; }
  body.in-game .game .scene svg { height: 30vh; }
}
