/* ЗАСОВ: Убежище — главный экран базы */

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

:root {
  --ink: #0a0908;
  --bone: #d0c4ae;
  --dim: #8a8272;
  --faint: #6d675c;
  --amber: #a8823e;
  --blood: #7a3f36;
  --blood-lt: #a05a4e;
  --line: #3c362c;
  --wood: #6d5340;
  --mono: "IBM Plex Mono", monospace;
  --serif: "Oranienbaum", serif;
}

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--ink);
  overscroll-behavior: none;
}
body {
  font-family: var(--mono);
  color: var(--bone);
  /* fixed вместо relative: iOS Safari игнорирует overflow:hidden на body
     и всё равно даёт резиновый скролл/pull-to-refresh — fixed это закрывает */
  position: fixed;
  inset: 0;
  -webkit-user-select: none; user-select: none;
  /* длинное нажатие на iOS: не показывать callout-меню (копировать/поделиться) */
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

/* UI-слои поверх карты: iOS игнорирует user-scalable=no, поэтому
   двойной-тап-зум глушим через touch-action. manipulation (а не none),
   чтобы внутренние скроллы (.plist, .jlist, .paper) продолжали работать */
#hud, #dock, #sheet, #sheet-backdrop, #night, #minigame, #dawn, #survival {
  touch-action: manipulation;
}

/* ---------- карта ---------- */

#viewport {
  position: absolute; inset: 0;
  overflow: hidden;
  touch-action: none;
  cursor: grab;
}
#viewport.dragging { cursor: grabbing; }

#world {
  position: absolute; top: 0; left: 0;
  width: 1000px; height: 1500px;
  will-change: transform;
}
.world-bg {
  position: absolute; inset: 0;
  background: url("../assets/asset-shelter-cutaway.png") 0 0 / 100% 100% no-repeat;
}

/* мерцающий свет комнат */
.glow {
  position: absolute;
  left: var(--x); top: var(--y);
  width: var(--size); height: var(--size);
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(255,170,70,.14) 0%, rgba(255,150,50,.05) 45%, transparent 70%);
  mix-blend-mode: screen;
  pointer-events: none;
  transition: opacity 2.5s ease;
  animation: glow-flicker var(--dur) steps(1) infinite;
}
@keyframes glow-flicker {
  0% { opacity: .9; } 13% { opacity: .55; } 27% { opacity: 1; } 41% { opacity: .7; }
  56% { opacity: .95; } 68% { opacity: .5; } 82% { opacity: .8; } 100% { opacity: .9; }
}
/* окно уснуло: город гасит свет раньше людей */
.glow--asleep { animation: none; opacity: .1; }
/* очаг потух — жилая не светится */
.glow--cold { animation: none; opacity: .12; }

/* ---------- признаки жизни: дом обитаем, но людей не видно ---------- */

/* тень в окне: кто-то прошёл внутри — свет на миг перекрыт (js: passShadow) */
.glow--shade::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent 33%, rgba(5,4,3,.9) 46%, rgba(5,4,3,.9) 54%, transparent 67%);
  animation: shade-pass .7s ease-in-out both;
  will-change: transform;
}
@keyframes shade-pass {
  from { transform: translateX(-52%); }
  to   { transform: translateX(52%); }
}

/* маленькая тень: ребёнок прошёл за окном — ниже и уже взрослой */
.glow--shade-kid::after {
  inset: 30% 0 0 0;
  background: linear-gradient(100deg, transparent 41%, rgba(5,4,3,.85) 48%, rgba(5,4,3,.85) 52%, transparent 59%);
}

/* взгляд из темноты (js: playEyesScene): окно второго этажа гаснет,
   и в стекле проступает пара холодных точек. Не свет и не лицо —
   ровно столько, чтобы усомниться, что видел */
.eyes {
  position: absolute;
  left: var(--x); top: var(--y);
  width: 42px; height: 56px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  opacity: 0;
  transition: opacity 2.6s ease;
  /* тёмное стекло: гасит нарисованный свет окна, края растушёваны под раму */
  background: radial-gradient(ellipse 72% 72% at 50% 50%,
    rgba(5,6,9,.88) 52%, rgba(5,6,9,.45) 78%, transparent 100%);
}
.eyes::before, .eyes::after {
  content: ""; position: absolute; top: 24px;
  width: 3px; height: 3px; border-radius: 50%;
  background: rgba(168,198,224,.35);
  box-shadow: 0 0 5px 1px rgba(150,185,215,.18);
}
.eyes::before { left: 15px; }
.eyes::after  { right: 15px; }
.eyes--on { opacity: 1; }
/* «дыхание»: суммарная видимость точек плавает в пределах ~0.15–0.35 */
.eyes--on::before, .eyes--on::after { animation: eyes-breathe 4.6s ease-in-out infinite; }
@keyframes eyes-breathe {
  0%, 100% { opacity: .45; }
  50% { opacity: 1; }
}
/* игрок посмотрел прямо — гаснут быстро, будто их и не было */
.eyes--out { transition: opacity .4s ease; }

/* мастерская пилит: окно мерцает чуть чаще и теплее */
.glow--work {
  animation-duration: .8s;
  background: radial-gradient(circle, rgba(255,185,90,.17) 0%, rgba(255,160,55,.06) 45%, transparent 70%);
}

/* все уложены — жилая дышит медленнее: дом успокоился */
.glow--calm { animation-duration: 3.8s; }

/* Гриша не лёг: в сумерках его окно горит холодным, когда остальные гаснут */
.glow--vigil {
  animation: none; opacity: .75;
  background: radial-gradient(circle, rgba(150,180,215,.16) 0%, rgba(130,160,200,.06) 45%, transparent 70%);
}
/* Гриша ушёл в ночь или погиб: окно спальни тёмное с того дня */
.glow--dark { animation: none; opacity: 0; }

/* дозорное окно: неподвижный силуэт — голова и плечи, ничего больше */
.watcher {
  position: absolute;
  left: var(--x); top: var(--y);
  width: 44px; height: 52px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  background: radial-gradient(ellipse 55% 65% at 50% 55%, rgba(165,185,205,.09), transparent 75%);
  opacity: 0;
  transition: opacity 5s ease;
}
.watcher::before, .watcher::after {
  content: ""; position: absolute; left: 50%;
  background: rgba(7,6,5,.82);
}
.watcher::before {
  top: 11px; width: 10px; height: 11px; margin-left: -5px;
  border-radius: 50% 50% 46% 46%;
}
.watcher::after {
  top: 20px; width: 22px; height: 25px; margin-left: -11px;
  border-radius: 10px 10px 2px 2px;
}
.watcher--seen { opacity: 1; }

/* струйка дыма над жилой: очаг горит — дом жив */
.smoke {
  position: absolute;
  left: var(--x); top: var(--y);
  width: 26px; height: 96px;
  transform: translate(-50%, -100%);
  pointer-events: none;
  filter: blur(2px);
}
.smoke::before, .smoke::after {
  content: ""; position: absolute; left: 50%; bottom: 0;
  width: 18px; height: 18px; margin-left: -9px; border-radius: 50%;
  background: radial-gradient(circle, rgba(205,198,182,.65), transparent 70%);
  opacity: 0;
  will-change: transform, opacity;
  animation: smoke-rise 7s linear infinite;
}
.smoke::after {
  width: 24px; height: 24px; margin-left: -12px;
  animation-duration: 9.5s; animation-delay: 3.6s;
}
@keyframes smoke-rise {
  0%   { transform: translate(0, 0) scale(.5); opacity: 0; }
  14%  { opacity: .5; }
  60%  { opacity: .26; }
  100% { transform: translate(7px, -80px) scale(1.7); opacity: 0; }
}

/* ---------- метки комнат ---------- */

.room {
  position: absolute;
  left: var(--x); top: var(--y);
  transform: translate(-50%, -50%);
  min-width: 132px; max-width: 168px;
  background: rgba(8,7,6,.84);
  border: 1px solid var(--line);
  border-left: 2px solid var(--wood);
  padding: 6px 9px;
  cursor: pointer;
}
.room:active { background: rgba(20,17,13,.92); }

.room .r-name {
  font-size: 9.5px; letter-spacing: 1px; color: var(--bone);
  display: flex; justify-content: space-between; gap: 8px; white-space: nowrap;
}
.room .r-name em { font-style: normal; color: var(--amber); }
.room .r-status { font-size: 8px; color: var(--dim); margin-top: 2px; }
.room .r-bar { height: 3px; background: rgba(255,255,255,.1); margin-top: 4px; }
.room .r-bar div { height: 100%; background: var(--amber); transition: width 1s linear; }

.room.room--alert { border-left-color: var(--blood); }
.room.room--alert .r-status { color: var(--blood-lt); }
.room.room--ready { border-left-color: var(--amber); }
.room.room--ready .r-status { color: var(--amber); animation: ready-blink 1.4s steps(1) infinite; }
@keyframes ready-blink { 0%, 65% { opacity: 1; } 66%, 100% { opacity: .4; } }

.room--build {
  border: 1px dashed var(--line); border-left: 1px dashed var(--line);
  opacity: .85; text-align: center;
}
.room--build .r-name { color: var(--dim); justify-content: center; }

/* этаж −3: свежий раскоп ниже дома — земля, крепь, полутьма */
.floor-deep {
  position: absolute;
  left: 2.5%; right: 2.5%;
  top: 100%; height: 470px;
  background:
    repeating-linear-gradient(90deg, transparent 0 118px, rgba(120,95,60,.10) 118px 124px),
    linear-gradient(180deg, rgba(26,21,14,.96) 0%, rgba(14,11,8,.98) 55%, rgba(6,5,4,1) 100%);
  border: 1px solid rgba(120,100,70,.22);
  border-top: 2px solid rgba(168,130,62,.35);
  box-shadow: inset 0 14px 30px rgba(0,0,0,.6);
}
/* раскоп дышит: земля внизу теплее, чем должна быть */
.floor-deep::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(ellipse 60% 40% at 50% 82%, rgba(168,130,62,.07), transparent 70%);
  animation: breathe 9s ease-in-out infinite;
}

/* закрытая «по-мирски» комната — не замок, а необжитый угол */
.room--locked { opacity: .55; border-left-color: var(--line); }
.room--locked .r-name { color: var(--dim); }
.room--locked .r-status { color: var(--faint); font-style: italic; }

/* комната-цель дня (туториал и вся игра): тёплая обводка, пульс вдвое медленнее тревоги */
.room--goal {
  border-color: var(--amber); border-left-color: var(--amber);
  animation: goal-pulse 2.8s ease-in-out infinite;
}
@keyframes goal-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(168,130,62,0); }
  50% { box-shadow: 0 0 0 5px rgba(168,130,62,.16); }
}

/* ---------- атмосфера ---------- */

/* догорающий день: тёплый фильтр густеет по закатному таймеру,
   последние ~30 секунд — холод и темнота (js/base.js: renderDusk) */
.dusk {
  position: absolute; inset: 0; pointer-events: none; z-index: 3;
  opacity: 0;
  transition: opacity 1.4s linear;
  will-change: opacity;
}
.dusk--warm { background: linear-gradient(180deg, rgba(150,88,30,.20) 0%, rgba(70,35,16,.32) 100%); }
.dusk--cold { background: linear-gradient(180deg, rgba(12,15,28,.48) 0%, rgba(5,6,12,.62) 100%); }

.vignette {
  position: absolute; inset: 0; pointer-events: none; z-index: 4;
  background: radial-gradient(ellipse at 50% 42%, transparent 40%, rgba(6,6,8,.55) 100%);
  animation: breathe 6s ease-in-out infinite;
}
@keyframes breathe { 0%, 100% { opacity: .75; } 50% { opacity: 1; } }

.grain {
  position: absolute; inset: 0; pointer-events: none; z-index: 5; opacity: .06;
  overflow: hidden;
}
.grain::before {
  content: ""; position: absolute; inset: -200%;
  background-image: repeating-conic-gradient(#fff 0% .0001%, transparent .0002% .0004%);
  animation: grain .4s steps(4) infinite;
}
@keyframes grain {
  0% { transform: translate(0,0); } 25% { transform: translate(-3%,2%); }
  50% { transform: translate(2%,-3%); } 75% { transform: translate(-1%,1%); } 100% { transform: translate(0,0); }
}

.edge { position: absolute; left: 0; right: 0; pointer-events: none; z-index: 6; }
.edge--top { top: 0; height: 130px; background: linear-gradient(rgba(10,9,8,.94), transparent); }
.edge--bottom { bottom: 0; height: 190px; background: linear-gradient(transparent, rgba(10,9,8,.96) 75%); }

/* ---------- HUD ---------- */

#hud { position: absolute; top: 0; left: 0; right: 0; z-index: 10; padding: 12px 14px 0; }
.hud-row { display: flex; justify-content: space-between; align-items: baseline; }
.hud-day { font-family: var(--serif); font-size: 17px; letter-spacing: 3px; color: #cfc8b8; }
.hud-res { display: flex; gap: 11px; font-size: 9px; color: var(--dim); }
.hud-res b { color: var(--bone); font-weight: 500; }
/* ресурс на нуле: впереди тёмная или голодная ночь — цифра кровит */
.hud-res b.res--out { color: var(--blood-lt); }
.hud-row--sub { margin-top: 3px; font-size: 8.5px; letter-spacing: 1.5px; color: var(--faint); }
.hud-sunset b { color: var(--blood-lt); font-weight: 500; }
.hud-note { color: var(--wood); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: rgba(109,83,64,.5); }
.hud-note--off { color: var(--faint); text-decoration-line: line-through; }

/* строка-цель: одна, всегда одна — ONBOARDING.md §2.1 */
.hud-goal {
  margin-top: 7px; padding: 6px 9px;
  background: rgba(8,7,6,.82); border: 1px solid #35312a; border-left: 2px solid var(--amber);
  font-size: 8.5px; letter-spacing: 1.5px; color: #c4b489;
  min-height: 12px;
}
.hud-goal:empty { display: none; }

/* ---------- док ---------- */

#dock { position: absolute; bottom: 0; left: 0; right: 0; z-index: 10; padding: 0 12px 18px; display: flex; flex-direction: column; gap: 9px; }
.event {
  font-size: 9.5px; line-height: 1.55; letter-spacing: .6px; color: #a39c8d;
  background: rgba(8,7,6,.88); border: 1px solid #35312a; border-left: 2px solid var(--blood);
  padding: 8px 10px;
}
.event b { color: var(--bone); font-weight: 500; }
.tabs { display: flex; gap: 7px; }
.tab {
  flex: 1; padding: 12px 4px; text-align: center;
  background: rgba(8,7,6,.88); border: 1px solid var(--line);
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 2px; color: var(--dim);
  cursor: pointer;
}
.tab--active { color: var(--bone); border-color: var(--wood); }

/* ---------- шторка комнаты ---------- */

#sheet-backdrop {
  position: absolute; inset: 0; z-index: 20;
  background: rgba(4,4,3,.55);
  opacity: 0; pointer-events: none; transition: opacity .25s;
}
#sheet-backdrop.open { opacity: 1; pointer-events: auto; }

#sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 21;
  background: #0d0c0a;
  border-top: 1px solid var(--wood);
  padding: 10px 16px 26px;
  transform: translateY(105%);
  transition: transform .34s cubic-bezier(.22, .8, .3, 1);
}
#sheet.open { transform: translateY(0); }

/* содержимое шторки проявляется мягко — как разложили бумаги на столе */
.sheet-body--in { animation: sheet-in .38s ease both; }
@keyframes sheet-in {
  from { opacity: 0; transform: translateY(7px); }
  to   { opacity: 1; transform: none; }
}

.sheet-grip { width: 34px; height: 2px; background: var(--line); margin: 0 auto 12px; }
.sheet-head { display: flex; justify-content: space-between; align-items: baseline; }
.sheet-title { font-family: var(--serif); font-size: 19px; letter-spacing: 2px; color: #cfc8b8; }
.sheet-title em { font-style: normal; font-family: var(--mono); font-size: 10px; color: var(--amber); margin-left: 6px; }
.sheet-status { font-size: 9px; color: var(--dim); }
.sheet-desc { font-size: 10.5px; line-height: 1.65; color: #a39c8d; margin-top: 10px; }

.sheet-workers { display: flex; gap: 7px; margin-top: 12px; flex-wrap: wrap; }
.worker {
  font-size: 8.5px; letter-spacing: 1px; color: var(--dim);
  border: 1px solid var(--line); padding: 5px 9px;
}
.worker b { color: var(--bone); font-weight: 500; }
.worker.worker--warn { border-color: #4d3430; color: var(--blood-lt); }

.sheet-actions { display: flex; gap: 8px; margin-top: 14px; }
.act {
  flex: 1; padding: 13px 6px; text-align: center;
  background: transparent; border: 1px solid var(--wood);
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 2px; color: var(--bone);
  cursor: pointer;
}
.act:active { background: rgba(109,83,64,.18); }
.act--dim { border-color: var(--line); color: var(--dim); }
.act--gold { border-color: var(--amber); color: var(--amber); }

/* ---------- вкладки: жители и дневник ---------- */

/* спальные места: лимит дома, путники сверятся с ним (DESIGN.md §1.2.3) */
.beds { margin-top: 8px; font-size: 8.5px; letter-spacing: 2.5px; color: var(--faint); }
/* внутренние скроллы: вертикальный пан разрешён, но не выходит за пределы списка
   (contain — чтобы докрутка не дёргала страницу и не будила pull-to-refresh) */
.plist { margin-top: 8px; max-height: 300px; overflow-y: auto; touch-action: pan-y; overscroll-behavior: contain; }
.prow {
  display: grid; grid-template-columns: 74px 108px 1fr; gap: 8px; align-items: baseline;
  padding: 8px 2px; border-bottom: 1px solid #211e18;
  font-size: 9px; letter-spacing: .5px;
}
.prow b { color: var(--bone); font-weight: 500; letter-spacing: 1.5px; }
.prow span { color: var(--dim); }
.prow i { font-style: normal; color: var(--faint); }
.prow--warn b, .prow--warn i { color: var(--blood-lt); }

/* правила дневника — трофеи, не справка (ONBOARDING.md §3) */
.rules-head { font-size: 8px; letter-spacing: 3px; color: var(--faint); margin-top: 10px; }
.rule { padding: 9px 2px; border-bottom: 1px solid #211e18; }
.rule-n { font-size: 8px; letter-spacing: 2.5px; color: var(--amber); }
.rule-t { font-size: 10px; line-height: 1.6; color: var(--bone); margin-top: 4px; }
.rule-w { font-size: 8px; letter-spacing: 1px; color: var(--faint); margin-top: 4px; text-align: right; }
.rule--locked .rule-n { color: var(--faint); }
.rule--locked .rule-t { color: var(--faint); letter-spacing: 4px; }

.jlist { margin-top: 8px; max-height: 320px; overflow-y: auto; touch-action: pan-y; overscroll-behavior: contain; }
.jline {
  font-size: 10px; line-height: 1.6; color: #a39c8d;
  padding: 9px 2px; border-bottom: 1px solid #211e18;
}
.jline:last-child { color: var(--bone); animation: jline-in 1.3s ease both; }
@keyframes jline-in { from { opacity: 0; } to { opacity: 1; } }

/* ---------- вылазка ---------- */

.txt-blood { color: var(--blood-lt); }

.rpoints { margin-top: 4px; }
.rpoint {
  border: 1px solid var(--line); border-left: 2px solid var(--wood);
  background: rgba(14,12,10,.6);
  padding: 9px 10px; margin-top: 8px; cursor: pointer;
}
.rpoint:active { background: rgba(30,25,19,.7); }
.rp-head { display: flex; justify-content: space-between; align-items: baseline; }
.rp-head b { font-size: 10px; letter-spacing: 1.5px; color: var(--bone); font-weight: 500; }
.rp-head span { font-size: 8px; letter-spacing: 1px; color: var(--dim); }
.rp-head span.rp-risk--high { color: var(--blood-lt); }
.rp-desc { font-size: 9px; line-height: 1.55; color: #8a8272; margin-top: 4px; }
.rp-meta { font-size: 8.5px; letter-spacing: 1px; color: var(--amber); margin-top: 6px; }

.mchips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.mchip {
  border: 1px solid var(--line); padding: 8px 10px;
  font-size: 8.5px; letter-spacing: 1px; color: var(--dim); cursor: pointer;
}
.mchip b { color: var(--bone); font-weight: 500; letter-spacing: 1.5px; }
.mchip--sel { border-color: var(--amber); }
.mchip--sel b { color: var(--amber); }
.mchip--dis { opacity: .4; border-style: dashed; cursor: default; }

.rsum { margin-top: 12px; font-size: 8.5px; letter-spacing: 1px; line-height: 1.8; color: var(--dim); }
.rsum b { color: var(--bone); font-weight: 500; }

.roll-line {
  margin-top: 12px; padding: 9px 10px;
  border: 1px solid var(--line); border-left: 2px solid var(--amber);
  font-size: 9.5px; letter-spacing: 1px; color: var(--dim);
}
.roll-line b { color: var(--amber); font-weight: 500; }

/* перекат кости: пока цифры катятся, итог занавешен (js/base.js: spinRoll) */
.sheet-body .sheet-desc, .sheet-body .rsum, .sheet-body .sheet-actions {
  transition: opacity .5s ease;
}
.roll-veil { transition: none; opacity: 0; pointer-events: none; }

.act--blood { border-color: var(--blood); color: var(--blood-lt); }

/* стена имён */
.wall { margin-top: 14px; border-top: 1px solid #211e18; padding-top: 10px; }
.wall .wt { font-size: 8px; letter-spacing: 3px; color: var(--faint); }
.wall .wn { font-size: 9px; letter-spacing: 1px; color: var(--blood-lt); margin-top: 6px; }

/* ---------- тост ---------- */

#toast {
  position: absolute; left: 50%; bottom: 132px; z-index: 30;
  transform: translate(-50%, 12px);
  background: rgba(10,9,8,.95); border: 1px solid var(--wood);
  padding: 9px 16px; font-size: 9.5px; letter-spacing: 1.5px; color: var(--bone);
  /* длинные тосты переносятся, а не обрезаются краем экрана */
  white-space: normal; max-width: 85vw; width: max-content;
  text-align: center; line-height: 1.5;
  opacity: 0; pointer-events: none;
  transition: opacity .25s, transform .25s;
}
#toast.toast--show { opacity: 1; transform: translate(-50%, 0); }
#toast.toast--danger { border-color: var(--blood); color: var(--blood-lt); }

.hud-sunset--late b { animation: late-blink 1s steps(1) infinite; }
@keyframes late-blink { 0%, 55% { opacity: 1; } 56%, 100% { opacity: .3; } }

/* ---------- ночь ---------- */

.hidden { display: none !important; }

#night {
  position: absolute; inset: 0; z-index: 40;
  background: #06060a; overflow: hidden;
  animation: night-in 1.2s ease-out;
}
@keyframes night-in { from { opacity: 0; } to { opacity: 1; } }

.night-shake { position: absolute; inset: 0; animation: knock 4.2s ease-in-out infinite; }
@keyframes knock {
  0%, 88% { transform: translate(0,0); }
  89% { transform: translate(-4px, 2px); }
  90.5% { transform: translate(4px, -2px); }
  92% { transform: translate(-3px, 1px); }
  93.5% { transform: translate(2px, -1px); }
  95%, 100% { transform: translate(0,0); }
}
.night-bg {
  position: absolute; inset: -14px;
  background: url("../assets/asset-shelter-gate.png") center/cover no-repeat;
  animation: drift 7s ease-in-out infinite alternate;
}
@keyframes drift {
  0%   { transform: translate(0, 0) scale(1.02); }
  50%  { transform: translate(5px, -3px) scale(1.03); }
  100% { transform: translate(-4px, 2px) scale(1.02); }
}
.night-lamp {
  position: absolute; left: -40px; top: 210px; width: 320px; height: 320px;
  background: radial-gradient(circle, rgba(255,166,60,.30) 0%, rgba(255,140,40,.10) 40%, transparent 70%);
  mix-blend-mode: screen;
  animation: glow-flicker 1.3s steps(1) infinite;
}
.night-fog {
  position: absolute; left: 148px; top: 128px; width: 190px; height: 100px;
  overflow: hidden; opacity: .5; filter: blur(2px);
}
.night-fog::before {
  content: ""; position: absolute; inset: -60px;
  background: radial-gradient(ellipse 80px 30px at 30% 50%, rgba(180,200,220,.5), transparent 70%),
              radial-gradient(ellipse 100px 40px at 70% 30%, rgba(160,180,200,.35), transparent 70%);
  animation: fogmove 9s linear infinite;
}
@keyframes fogmove { from { transform: translateX(-40px); } to { transform: translateX(60px); } }

.night-grad {
  position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(rgba(6,6,10,.75) 0%, rgba(6,6,10,0) 14%, rgba(6,6,10,0) 52%, rgba(6,6,10,.92) 86%);
}

/* кромка экрана пульсирует в такт сердцу, пока палец на засове */
.night-pulse {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at 50% 55%, transparent 52%, rgba(122,63,54,.30) 100%);
  opacity: 0;
  transition: opacity .9s ease;
  will-change: opacity;
}
#night.night--holding .night-pulse {
  animation: edge-heart 1.2s ease-in-out infinite;
}
@keyframes edge-heart {
  0%, 100% { opacity: .3; }
  12% { opacity: .8; }
  24% { opacity: .35; }
  36% { opacity: .6; }
  48% { opacity: .35; }
}

.night-ui { position: absolute; inset: 0; display: flex; flex-direction: column; }
.night-head { display: flex; justify-content: space-between; padding: 12px 14px; }
.night-title { font-family: var(--serif); font-size: 15px; letter-spacing: 3px; color: #cfc8b8; }
.night-meter { font-size: 9.5px; color: var(--dim); }
.night-meter b { color: var(--bone); font-weight: 500; }
.night-spacer { flex: 1; }

.night-whisper {
  text-align: center; padding: 0 40px 14px;
  font-family: var(--serif); font-size: 19px; letter-spacing: 1px; font-style: italic;
  color: #cfc8b8; text-shadow: 0 0 20px rgba(0,0,0,.95);
  animation: whisper-glow 3s ease-in-out infinite;
}
@keyframes whisper-glow {
  0%, 100% { opacity: .85; }
  50% { opacity: 1; text-shadow: 0 0 26px rgba(0,0,0,1), 0 0 8px rgba(200,190,170,.15); }
}
/* пауза между событиями: шёпот тает и медленно возвращается (js: swapWhisper) */
.night-whisper--in {
  animation: whisper-in 1.5s ease both, whisper-glow 3s ease-in-out 1.5s infinite;
}
@keyframes whisper-in { from { opacity: 0; } to { opacity: .85; } }
.night-whisper--out { animation: none; opacity: 0; transition: opacity .8s ease; }
.night-whisper small {
  display: block; margin-top: 8px;
  font-family: var(--mono); font-size: 8.5px; letter-spacing: 3px;
  color: var(--blood); font-style: normal;
}

.night-holdzone { display: flex; flex-direction: column; align-items: center; gap: 12px; padding-bottom: 34px; }
.night-mentor {
  max-width: 300px; text-align: center;
  font-size: 8.5px; letter-spacing: 1.5px; line-height: 1.7; color: var(--dim);
  text-shadow: 0 0 14px rgba(0,0,0,.9);
}
.night-noise { width: 210px; height: 4px; background: rgba(255,255,255,.1); overflow: hidden; }
.night-noise div { width: 0%; height: 100%; background: var(--blood); transition: width .5s; }
.night-noise-label { font-size: 8.5px; letter-spacing: 3px; color: var(--blood-lt); animation: label-blink 1.2s steps(1) infinite; }
@keyframes label-blink { 0%, 60% { opacity: 1; } 61%, 100% { opacity: .35; } }

.night-hold {
  width: 118px; height: 118px; border-radius: 50%;
  border: 1.5px solid var(--wood); background: rgba(10,9,8,.55);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  box-shadow: 0 0 0 10px rgba(109,83,64,.08), 0 0 40px rgba(0,0,0,.8);
  cursor: pointer; touch-action: none;
  animation: heart 1.2s ease-in-out infinite;
}
@keyframes heart {
  0%, 100% { transform: scale(1); }
  12% { transform: scale(1.05); }
  24% { transform: scale(1); }
  36% { transform: scale(1.03); }
  48% { transform: scale(1); }
}
.night-hold .t { font-size: 11px; letter-spacing: 3px; color: var(--bone); }
.night-hold .s { font-size: 8px; letter-spacing: 2px; color: var(--dim); }
.night-hold--active {
  border-color: var(--amber);
  box-shadow: 0 0 0 14px rgba(168,130,62,.12), 0 0 40px rgba(0,0,0,.8);
}
.night-hold--active .t { color: var(--amber); }
/* последние секунды: рука устала — кнопка мелко дрожит */
.night-hold--strain { animation: hold-strain .42s steps(2) infinite; }
@keyframes hold-strain {
  0%, 100% { transform: translate(0, 0) scale(1.02); }
  25% { transform: translate(-1px, 1px) scale(1.02); }
  50% { transform: translate(1px, -1px) scale(1.03); }
  75% { transform: translate(-1px, -1px) scale(1.02); }
}
.night-timer { font-size: 9px; letter-spacing: 4px; color: var(--faint); }

.night-open {
  position: relative;
  margin-top: 6px; padding: 12px 26px;
  background: rgba(10,9,8,.7); border: 1px solid var(--blood);
  font-family: var(--mono); font-size: 9px; letter-spacing: 2.5px; color: var(--blood-lt);
  cursor: pointer;
  animation: open-pulse 2.6s ease-in-out infinite;
}
@keyframes open-pulse {
  0%, 100% { opacity: .75; }
  50% { opacity: 1; }
}
/* Ночь Отсчёта: кнопка «ВЫПУСТИТЬ» тлеет изнутри — медленно, как угли */
.night-open--ember::after {
  content: ""; position: absolute; inset: 0;
  box-shadow: inset 0 0 18px rgba(122,63,54,.55);
  opacity: 0;
  animation: ember 3.6s ease-in-out infinite;
}
@keyframes ember {
  0%, 100% { opacity: .15; }
  50% { opacity: .8; }
}
/* при рассудке <25% «открыть» выглядит как правильный выбор — DESIGN.md §4.2 */
.night-open--lure { border-color: var(--amber); color: var(--amber); }

/* ---------- мини-игры: занятие рук поверх карты (MINIGAMES.md) ---------- */

#minigame {
  position: absolute; inset: 0; z-index: 26;
  background: rgba(6, 6, 8, .94);
  animation: night-in .7s ease-out;
}
.mg-ui {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  padding: 22px 18px 26px;
}
.mg-head { text-align: center; }
.mg-title { font-family: var(--serif); font-size: 21px; letter-spacing: 3px; color: #cfc8b8; }
.mg-sub { font-size: 8.5px; letter-spacing: 2px; color: var(--dim); margin-top: 5px; }
.mg-body {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 18px;
  width: 100%;
}
.mg-foot { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.mg-leave { width: 180px; flex: none; }
.mg-noise { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.mg-noise .night-noise div { width: 0%; height: 100%; background: var(--blood); transition: width .5s; }
.mg-noise-label { font-size: 8px; letter-spacing: 3px; color: var(--blood-lt); }

.mg-caption {
  max-width: 300px; text-align: center;
  font-size: 8.5px; letter-spacing: 1.5px; line-height: 1.7; color: var(--dim);
}
.mg-record { font-size: 9px; letter-spacing: 3px; color: var(--amber); }

/* М1 «Поймай волну»: голос проступает из шума, верньер под пальцем */
.mg-voice {
  min-height: 58px; padding: 0 30px; text-align: center;
  font-family: var(--serif); font-size: 18px; font-style: italic; letter-spacing: 1px;
  color: #cfc8b8; text-shadow: 0 0 18px rgba(0,0,0,.9);
  transition: opacity .3s linear;
}
.mg-voice b { color: var(--blood-lt); font-weight: 500; font-style: normal; }
.mg-dial {
  position: relative; width: 300px; height: 64px;
  border: 1px solid var(--line); background: rgba(10,9,8,.7);
  touch-action: none; cursor: pointer;
}
.mg-dial-scale {
  position: absolute; inset: 10px 8px;
  background: repeating-linear-gradient(90deg, rgba(208,196,174,.22) 0 1px, transparent 1px 14px);
}
.mg-dial-scale::after {
  content: ""; position: absolute; left: 0; right: 0; top: 50%;
  border-top: 1px solid rgba(208,196,174,.18);
}
.mg-dial-knob {
  position: absolute; top: 4px; bottom: 4px; width: 3px; margin-left: -1.5px;
  background: var(--amber);
  box-shadow: 0 0 9px rgba(168,130,62,.55);
}

/* М2 «Тихий ремонт»: треснувший засов, удар в скрип */
.mg-bolt {
  position: relative; width: 250px; height: 44px;
  border: 1px solid var(--line); background: rgba(14,12,10,.8);
}
.mg-bolt-bar {
  position: absolute; left: 12px; right: 12px; top: 15px; height: 14px;
  background: linear-gradient(180deg, #55432f, #3a2d1f);
}
.mg-bolt-crack {
  position: absolute; left: 46%; top: 8px; bottom: 8px; width: 2px;
  background: var(--blood);
  transform: rotate(9deg);
  transition: opacity .6s;
}
.mg-hammer {
  width: 128px; height: 128px; border-radius: 50%;
  border: 1.5px solid var(--wood); background: rgba(10,9,8,.55);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  box-shadow: 0 0 0 10px rgba(109,83,64,.08), 0 0 40px rgba(0,0,0,.8);
  cursor: pointer; touch-action: none;
}
.mg-hammer .t { font-size: 12px; letter-spacing: 3px; color: var(--bone); }
.mg-hammer .s { font-size: 8px; letter-spacing: 2px; color: var(--dim); }
.mg-hammer:active { border-color: var(--amber); }
/* вспышка-подсказка: дом скрипнул — окно для удара открыто */
#minigame.mg--cue .mg-hammer {
  border-color: var(--amber);
  box-shadow: 0 0 0 14px rgba(168,130,62,.14), 0 0 40px rgba(0,0,0,.8);
}
#minigame.mg--cue .mg-hammer .s { color: var(--amber); }

/* М5 «Глазок»: кадр улицы, вчера/сегодня */
.mg-frame {
  padding: 8px;
  border: 1px solid var(--wood); border-radius: 50% / 14%;
  background: #060505;
  box-shadow: inset 0 0 34px rgba(0,0,0,.95), 0 0 30px rgba(0,0,0,.7);
}
.mg-scene {
  position: relative; width: 320px; height: 220px; overflow: hidden;
  background: linear-gradient(180deg, #0e1016 0%, #12100c 70%, #0c0b09 100%);
}
.mg-scene--memory { filter: brightness(.72) sepia(.28); }
.mgs-road { position: absolute; left: 0; right: 0; top: 182px; height: 38px; background: #0a0908; border-top: 1px solid rgba(208,196,174,.10); }
.mgs-house { position: absolute; left: 10px; top: 58px; width: 118px; height: 124px; background: #16130e; border-top: 3px solid #1d1912; }
.mgs-window {
  position: absolute; left: 54px; top: 92px; width: 26px; height: 32px;
  background: #262019;
  box-shadow: inset 0 0 0 2px #14110c;
}
.mgs-window::after { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 2px; background: #14110c; }
.mgs-window-open .mgs-window { background: #030303; }
.mgs-window-open .mgs-window::after { content: none; }
.mgs-fence { position: absolute; left: 140px; top: 152px; width: 176px; height: 30px;
  background: repeating-linear-gradient(90deg, #1a1610 0 7px, #0e0c09 7px 12px); }
.mgs-gate {
  position: absolute; left: 170px; top: 150px; width: 24px; height: 32px;
  background: repeating-linear-gradient(90deg, #241e14 0 5px, #171310 5px 8px);
  transform-origin: left bottom;
}
.mgs-gate-open .mgs-gate { transform: rotate(-22deg); background: repeating-linear-gradient(90deg, #241e14 0 5px, #171310 5px 8px); box-shadow: 6px 2px 8px rgba(0,0,0,.6); }
.mgs-lamp { position: absolute; left: 262px; top: 58px; width: 3px; height: 124px; background: #1c1811; }
.mgs-lamp::before { content: ""; position: absolute; left: -5px; top: -6px; width: 13px; height: 6px; background: #1c1811; }
.mgs-lamplight {
  position: absolute; left: 246px; top: 40px; width: 34px; height: 34px; border-radius: 50%;
  background: radial-gradient(circle, rgba(220,180,100,.5) 0%, rgba(200,150,70,.16) 45%, transparent 70%);
}
.mgs-lamp-off .mgs-lamplight { background: radial-gradient(circle, rgba(60,55,45,.25) 0%, transparent 60%); }
.mgs-linen { position: absolute; left: 128px; top: 96px; width: 134px; height: 26px; }
.mgs-linen::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 1px; background: rgba(208,196,174,.22); }
.mgs-linen i {
  position: absolute; top: 1px; width: 16px; height: 20px;
  background: rgba(160,150,128,.30);
}
.mgs-linen i:nth-child(1) { left: 22px; }
.mgs-linen i:nth-child(2) { left: 58px; height: 15px; }
.mgs-linen i:nth-child(3) { left: 96px; height: 22px; }
.mgs-linen-gone .mgs-linen i { opacity: 0; }
.mgs-car { position: absolute; left: 96px; top: 168px; width: 84px; height: 18px; background: #14110d; border-radius: 4px 8px 2px 2px; }
.mgs-car::before { content: ""; position: absolute; left: 18px; top: -9px; width: 42px; height: 10px; background: #14110d; border-radius: 5px 7px 0 0; }
.mgs-cardoor {
  position: absolute; left: 16px; top: -18px; width: 3px; height: 15px;
  background: #1f1a13; opacity: 0;
  transform-origin: bottom;
}
.mgs-car-open .mgs-cardoor { opacity: 1; transform: rotate(-26deg); }
.mgs-car-open .mgs-car { box-shadow: inset 8px 0 6px -4px rgba(3,3,3,.9); }
.mgs-man { position: absolute; left: 292px; top: 152px; width: 9px; height: 30px;
  background: #0b0a08; border-radius: 4px 4px 0 0; }
.mgs-man::before { content: ""; position: absolute; left: 50%; top: -7px; width: 7px; height: 7px; margin-left: -3.5px; border-radius: 50%; background: #0b0a08; }
.mgs-man-near .mgs-man { left: 252px; top: 142px; width: 12px; height: 40px; }
.mgs-man--none .mgs-man { display: none; }
.mgs-hit {
  position: absolute; width: 46px; height: 46px; margin: -8px;
  cursor: pointer;
}
.mgs-hit--found { border: 1px solid var(--blood); box-shadow: 0 0 10px rgba(122,63,54,.4); }
.mg-actions { width: 100%; max-width: 320px; }

/* М6 «Колыбельная»: линия дыхания, огонёк задаёт темп */
.mg-lull {
  position: relative; width: 320px; height: 190px;
  border: 1px solid var(--line); background: rgba(10,9,8,.7);
  touch-action: none; cursor: pointer;
}
.mg-lull svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.mg-lull-path { fill: none; stroke: rgba(208,196,174,.26); stroke-width: 1.5; }
.mg-lull-done { fill: none; stroke: var(--amber); stroke-width: 2; opacity: .75; }
.mg-lull-dot {
  position: absolute; width: 13px; height: 13px; margin: -6.5px 0 0 -6.5px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 14px rgba(168,130,62,.55);
  pointer-events: none;
}

/* ---------- рассвет ---------- */

#dawn {
  position: absolute; inset: 0; z-index: 50;
  background: #0a0908;
  display: flex; align-items: center; justify-content: center;
  animation: dawn-in 1.4s ease-out;
}
@keyframes dawn-in { from { opacity: 0; } to { opacity: 1; } }

.dawn-inner { padding: 0 34px; max-width: 390px; text-align: center; }
.dawn-title {
  font-family: var(--serif); font-size: 34px; letter-spacing: 8px; color: #cfc8b8;
  margin-bottom: 22px;
}
.dawn-lines p {
  font-size: 10.5px; line-height: 1.7; letter-spacing: .5px; color: #a39c8d;
  margin-bottom: 12px;
  /* итоги ночи проявляются по строке — утро вспоминается не сразу */
  opacity: 0;
  animation: dawn-line .9s ease both;
  animation-delay: calc(var(--i, 0) * .4s + .3s);
}
.dawn-lines p:nth-child(even) { color: var(--dim); font-size: 9px; letter-spacing: 2px; }
@keyframes dawn-line {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}
.dawn-btn { width: 100%; margin-top: 18px; opacity: 0; animation: dawn-line 1s ease both; }

/* ---------- листок «КАК ВЫЖИТЬ» (ONBOARDING.md §4) ---------- */

#survival {
  position: absolute; inset: 0; z-index: 60;
  background: rgba(5,4,3,.9);
  display: flex; align-items: center; justify-content: center;
  padding: 20px 16px;
  animation: dawn-in .5s ease-out;
}
.paper {
  position: relative;
  max-width: 330px; max-height: 100%; overflow-y: auto;
  touch-action: pan-y; overscroll-behavior: contain;
  background: linear-gradient(173deg, #cfc4a3 0%, #c2b590 52%, #b3a37c 100%);
  color: #2c261a;
  padding: 30px 22px 18px;
  box-shadow: 0 12px 50px rgba(0,0,0,.9);
  transform: rotate(-1.2deg);
  font-family: var(--mono);
}
.paper-nail {
  position: absolute; top: 9px; left: 50%; transform: translateX(-50%);
  width: 9px; height: 9px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #8a7a5c, #4a3d28 70%);
  box-shadow: 0 2px 3px rgba(44,38,26,.6);
}
.paper-title { font-size: 13px; letter-spacing: 3px; font-weight: 500; text-align: center; }
.paper-sub { font-size: 8.5px; letter-spacing: 1px; text-align: center; margin-top: 3px; color: #5c503a; font-style: italic; }
.paper p { font-size: 9.5px; line-height: 1.75; letter-spacing: .4px; margin-top: 12px; }
.paper-h { font-size: 10px; letter-spacing: 3px; font-weight: 500; margin-top: 16px; border-bottom: 1px solid rgba(44,38,26,.35); padding-bottom: 3px; }
.paper-torn { color: #5c503a; font-style: italic; font-size: 8.5px !important; }
.paper-strike { text-decoration: line-through; text-decoration-thickness: 1.5px; color: #4a3d28; }
.paper-pencil {
  font-family: var(--serif); font-style: italic; font-size: 12px !important;
  color: #55442e; transform: rotate(-.8deg); margin-top: 4px !important;
}
.paper-close {
  width: 100%; margin-top: 18px;
  border-color: #5c503a; color: #3c3222;
}

/* ---------- титул и пролог (ONBOARDING.md §0) ---------- */

#title {
  position: absolute; inset: 0; z-index: 80;
  background: #000; /* чернее игрового фона: титул холоднее дома */
  display: flex; align-items: center; justify-content: center;
  text-align: center;
  transition: opacity 1s ease;
}
#title.title--out { opacity: 0; pointer-events: none; }
.title-name {
  font-family: var(--serif);
  font-size: 44px; letter-spacing: 18px; margin-left: 18px; /* компенсация разрядки */
  color: var(--bone);
}
.title-invite {
  margin-top: 26px;
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 2px;
  color: var(--bone); opacity: .5;
  animation: title-breathe 4s ease-in-out infinite;
}
@keyframes title-breathe { 0%, 100% { opacity: .5; } 50% { opacity: .18; } }
.title-menu { margin-top: 30px; display: flex; flex-direction: column; gap: 12px; align-items: center; }
.title-act {
  background: none; border: 1px solid var(--line);
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 2px;
  color: var(--bone); padding: 10px 22px; cursor: pointer;
  min-width: 230px;
}
.title-act:active { background: rgba(109,83,64,.18); }
.title-warn {
  font-family: var(--mono); font-size: 9px; letter-spacing: 1px;
  color: var(--dim); max-width: 250px; line-height: 1.7; margin-bottom: 4px;
}

#prologue {
  position: absolute; inset: 0; z-index: 79;
  background: #000;
  transition: opacity 1.5s ease;
}
#prologue.pro--out { opacity: 0; pointer-events: none; }
.pro-screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; justify-content: center;
  padding: 0 30px; gap: 13px;
  opacity: 0; pointer-events: none;
  transition: opacity .6s ease;
}
.pro-screen.pro--on { opacity: 1; }
.pro-screen span {
  font-family: var(--mono); font-size: 10.5px; line-height: 1.75;
  letter-spacing: .6px; color: var(--bone); max-width: 340px;
  opacity: 0; transform: translateY(7px);
  transition: opacity .8s ease, transform .8s ease;
}
/* строки лесенкой: сдвиг вверх + прозрачность, задержки по порядку */
.pro-screen.pro--on span { opacity: .92; transform: translateY(0); }
.pro-screen.pro--on span:nth-child(1) { transition-delay: .15s; }
.pro-screen.pro--on span:nth-child(2) { transition-delay: .9s; }
.pro-screen.pro--on span:nth-child(3) { transition-delay: 1.65s; }
.pro-screen.pro--on span:nth-child(4) { transition-delay: 2.4s; }
.pro-skip {
  position: absolute; bottom: 26px; left: 0; right: 0;
  text-align: center;
  font-family: var(--mono); font-size: 8.5px; letter-spacing: 2px;
  color: var(--bone); opacity: .35;
  padding: 10px; cursor: pointer;
}

/* ---------- prefers-reduced-motion: декоративное движение — выключить ---------- */

@media (prefers-reduced-motion: reduce) {
  .night-shake, .night-bg, .night-fog::before, .grain::before,
  .night-hold, .night-hold--strain, .night-pulse,
  .smoke::before, .smoke::after,
  .room--goal, .floor-deep::after { animation: none !important; }
  .glow--shade::after { content: none; }
  .watcher { transition: none; }
  /* глаза без дыхания и без фейдов: просто появились — просто исчезли */
  .eyes, .eyes--out { transition: none; }
  .eyes--on::before, .eyes--on::after { animation: none; }
  .night-whisper, .night-whisper--in { animation: none !important; opacity: .9; }
  .night-whisper--out { opacity: 0; }
  .dawn-lines p, .dawn-btn {
    animation-duration: .01s !important;
    animation-delay: 0s !important;
  }
  .sheet-body--in { animation: none; }
  .dusk { transition: none; }
  /* пролог: без сдвигов и пульса — только кроссфейды прозрачности (§0.4) */
  .title-invite { animation: none; }
  .pro-screen span { transform: none; transition: opacity .8s ease; }
  /* мини-игры: вспышка-подсказка остаётся (она функциональна), резкое — нет */
  #minigame { animation: none; }
  .mg-voice { transition: none; }
  .mg-noise .night-noise div { transition: none; }
}
