html, body {
  margin: 0;
  padding: 0;
  background: #000;
  overflow: hidden;
  height: 100%;
  font-family: "Consolas", "Courier New", monospace;
}

#app {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}

#stage {
  position: relative;
  width: min(100vw, calc(100vh * 16 / 9));
  height: min(100vh, calc(100vw * 9 / 16));
  background: #000;
  overflow: hidden;
  user-select: none;
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  display: block;
}

/* ---------- letterbox ---------- */
.letterbox {
  position: absolute;
  left: 0;
  right: 0;
  height: 0;
  background: #000;
  transition: height 700ms cubic-bezier(.4, 0, .2, 1);
  pointer-events: none;
  z-index: 20;
}
#letterbox-top { top: 0; }
#letterbox-bottom { bottom: 0; }
.cinema #letterbox-top,
.cinema #letterbox-bottom { height: 11%; }

/* ---------- fade ---------- */
#fade {
  position: absolute;
  inset: 0;
  background: #000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 900ms ease;
  z-index: 30;
}
#fade.on { opacity: 1; }

/* ---------- уровень 6: взгляд на тамбур сквозь овальный лаз ---------- */
/* Мы смотрим снаружи корабля в овальный люк, поэтому кадр обрезан овалом:
   чёрное поле — обшивка, в середине — прорезь. Включается и выключается
   под затемнением (enterTambour / enterCorridor), поэтому переходов нет:
   под virtual-time-budget они всё равно не докручиваются (п. 28 HANDOFF). */
#hatchview {
  position: absolute;
  left: 15%;
  right: 15%;
  top: 7%;
  bottom: 7%;
  border-radius: 50%;
  pointer-events: none;
  z-index: 21;
  opacity: 0;
  /* всё, что вокруг овала, — обшивка корабля. Большой spread вместо
     радиального градиента: градиент на апскейле давал мутное серое пятно. */
  box-shadow: 0 0 0 60vmax #04060a;
}
#hatchview.on { opacity: 1; }
/* кромка лаза и тень внутрь — чтобы овал читался металлом, а не вырезом */
#hatchview::after {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: 50%;
  box-shadow:
    inset 0 0 0 1px rgba(120, 134, 142, 0.34),
    inset 0 0 26px 10px rgba(0, 0, 0, 0.55);
}

/* панель взлома замка: поверх овального лаза, ниже субтитров */
#pickpanel {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 34.4%;
  height: auto;
  image-rendering: pixelated;
  z-index: 22;
  display: none;
  pointer-events: none;
}
#pickpanel.on { display: block; }

/* ---------- уровень 7: экран экзамена и планшет теста ---------- */
/* Оба холста — во весь кадр: камера «ныряет» в монитор, и это читается как
   крупный план, а не как интерфейс поверх игры. Планшету нужен мышиный ввод,
   поэтому pointer-events включён только у него; клики по нему не должны
   доходить до диалога (stopPropagation в уровне, как у #lock).
   Уровень 8 добавил сюда же #memsession — сеанс коммутатора: та же логика,
   крупный план чужой памяти без мыши, только клавиши. */
#memsession, #examscreen, #karnad, #barrier, #doorhack, #locks {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  z-index: 22;
  display: none;
  pointer-events: none;
}
#memsession.on, #examscreen.on, #karnad.on, #barrier.on, #doorhack.on, #locks.on { display: block; }
#karnad { cursor: crosshair; }
#karnad.on { pointer-events: auto; }
#doorhack { cursor: pointer; }
#doorhack.on { pointer-events: auto; }

/* ---------- веки: «закрываем глаза» на проверке радиации (глава 4) ---------- */
/* Две створки с круглой ведущей кромкой съезжаются и смыкаются в чёрноту.
   Ниже #fade (30) и выше субтитров (25): во время черноты текст не просвечивает. */
#blink {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 29;
  overflow: hidden;
}
#blink .lid {
  position: absolute;
  left: -8%;
  right: -8%;
  height: 58%;
  background: #05070a;
  will-change: transform;
}
#blink .lid-top {
  top: 0;
  transform: translateY(-101%);
  border-radius: 0 0 50% 50% / 0 0 36px 36px;
  box-shadow: 0 10px 22px rgba(0, 0, 0, .9);
  transition: transform 760ms cubic-bezier(.4, 0, .62, 1);
}
#blink .lid-bottom {
  bottom: 0;
  transform: translateY(101%);
  border-radius: 50% 50% 0 0 / 36px 36px 0 0;
  box-shadow: 0 -10px 22px rgba(0, 0, 0, .9);
  transition: transform 760ms cubic-bezier(.4, 0, .62, 1);
}
#blink.on .lid-top { transform: translateY(0); }
#blink.on .lid-bottom { transform: translateY(0); }
/* для отладки: мгновенно закрытые веки без анимации (headless не докручивает
   CSS-переходы под виртуальным временем) */
#blink.noanim .lid { transition: none !important; }
/* открываются медленнее, чем закрываются — как настоящие веки */
#blink.opening .lid {
  transition: transform 1150ms cubic-bezier(.25, .55, .35, 1);
}

/* нижний градиент под субтитры */
#shade {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 34%;
  background: linear-gradient(to top, rgba(0,0,0,.82), rgba(0,0,0,.38) 46%, rgba(0,0,0,0));
  pointer-events: none;
  z-index: 23;
}

/* ---------- subtitles ---------- */
#subtitles {
  position: absolute;
  left: 10%;
  right: 10%;
  bottom: 5.5%;
  text-align: center;
  color: #e9e4d4;
  text-shadow: 0 2px 0 #000, 0 0 8px #000;
  pointer-events: none;
  opacity: 0;
  transition: opacity 220ms ease;
  z-index: 25;
}
#subtitles.on { opacity: 1; }
#speaker {
  font-size: clamp(9px, 0.95vw, 12px);
  letter-spacing: 0.18em;
  color: #c9a227;
  margin-bottom: 0.35em;
  text-transform: uppercase;
}
#line {
  font-size: clamp(12px, 1.28vw, 18px);
  line-height: 1.35;
}

/* ---------- choices ---------- */
#choices {
  position: absolute;
  left: 50%;
  bottom: 13%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3em;
  text-align: center;
  z-index: 26;
  pointer-events: none;
  opacity: 0;
  transition: opacity 180ms ease;
}
#choices.on { opacity: 1; pointer-events: auto; }
.choice {
  font-size: clamp(11px, 1.1vw, 15px);
  color: #ddd6c4;
  background: none;
  padding: 0.18em 0.6em;
  cursor: pointer;
  text-shadow: 0 2px 5px #000, 0 0 12px #000;
}
.choice:hover {
  color: #f0d27a;
}
.choice .num { color: #9c8a5e; margin-right: 0.8em; }

/* ---------- hint ---------- */
#hint {
  position: absolute;
  right: 4%;
  bottom: 4%;
  color: #d3c9ae;
  background: rgba(0, 0, 0, 0.35);
  padding: 0.25em 0.7em;
  text-shadow: 0 1px 3px #000;
  font-size: clamp(9px, 0.9vw, 12px);
  letter-spacing: 0.12em;
  opacity: 0;
  transition: opacity 500ms ease;
  z-index: 22;
  pointer-events: none;
}
#hint.on { opacity: .9; }

/* ---------- подсказка у точки интереса (глава 8) ---------- */
/* Действие показывается у самого объекта, а не в углу: угол занят только
   «A / D — идти». Позицию в процентах кадра считает ui.hotLabel() из world-
   координат точки и текущей камеры, поэтому подпись не уезжает при наездах. */
#hotlabel {
  position: absolute;
  transform: translate(-50%, -100%);
  background: rgba(8, 12, 16, 0.84);
  border: 1px solid rgba(201, 162, 39, 0.55);
  color: #f0e2b0;
  padding: 0.3em 0.8em;
  font-size: clamp(13.5px, 1.35vw, 18px);
  font-weight: 600;
  letter-spacing: 0.10em;
  text-shadow: 0 1px 3px #000;
  white-space: nowrap;
  z-index: 24;
  display: none;
  pointer-events: none;
}
#hotlabel.on { display: block; }

/* ---------- счётчик времени «Реверса» (глава 9) ---------- */
/* Висит сверху по центру, только пока идёт сцена с таймером. Цвет — тёплый
   янтарь, как лампы второго поста; на последних секундах уровень добавляет
   класс .low и счётчик краснеет. */
#countdown {
  position: absolute;
  top: 4%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 24;
  display: none;
  padding: 0.15em 0.55em;
  background: rgba(6, 12, 15, 0.72);
  border: 1px solid rgba(216, 166, 42, 0.35);
  color: #e8c47a;
  font-size: clamp(14px, 1.8vw, 22px);
  letter-spacing: 0.18em;
  text-shadow: 0 1px 3px #000;
  pointer-events: none;
}
#countdown.on { display: block; }
#countdown.low { color: #e06a4a; border-color: rgba(224, 106, 74, 0.55); }

/* ---------- dossier ---------- */
#dossier {
  position: absolute;
  inset: 0;
  background: #050505;
  color: #b9c9a8;
  padding: 8% 9%;
  box-sizing: border-box;
  z-index: 40;
  display: flex;
  flex-direction: column;
  justify-content: center;
  opacity: 0;
  transition: opacity 500ms ease;
  pointer-events: none;
}
#dossier.on { opacity: 1; pointer-events: auto; }
#dossier::before {
  content: 'АРХИВ СВБ // ЗАШИФРОВАННАЯ ПЕРЕДАЧА';
  color: #4e5b43;
  letter-spacing: 0.3em;
  font-size: clamp(8px, 0.78vw, 11px);
  margin-bottom: 2.2em;
}
#dossier-text {
  margin: 0;
  white-space: pre-wrap;
  font-family: inherit;
  font-size: clamp(9px, 1.02vw, 14px);
  line-height: 1.55;
  letter-spacing: 0.02em;
  color: #a9bd97;
  text-shadow: 0 0 6px rgba(120, 180, 90, 0.25);
  max-height: 74%;
  overflow: hidden;
}
#dossier-skip {
  margin-top: 2em;
  font-size: clamp(8px, 0.8vw, 11px);
  color: #4e5b43;
  letter-spacing: 0.2em;
  opacity: 0;
  transition: opacity 600ms ease;
}
#dossier-skip.on { opacity: 1; }
#dossier-text::after {
  content: '▌';
  color: #7fa06a;
  animation: blink 1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* Глава 18: шапка-досье не на чёрном, а поверх орбиты Марса.
   Текст — лог терминала слева, станция остаётся видна внизу слева. */
#dossier-view {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  display: none;
  z-index: 0;
}
#dossier.with-view {
  background: #050505;
  padding: 6.5% 8%;
  justify-content: flex-start;
  align-items: flex-start;
}
#dossier.with-view #dossier-view { display: block; }
#dossier.with-view::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(3, 6, 9, 0.62) 0%, rgba(3, 6, 9, 0.18) 48%, rgba(3, 6, 9, 0) 70%),
    linear-gradient(90deg, rgba(3, 6, 9, 0.68) 0%, rgba(3, 6, 9, 0.30) 46%, rgba(3, 6, 9, 0) 76%);
}
#stage.lang-en #dossier::before { content: 'BIS ARCHIVE // ENCRYPTED TRANSMISSION'; }
#stage.lang-en #dossier.with-view::before { content: 'MCLXXXIV-BC // LOCAL TRANSMISSION'; }
#dossier.with-view::before {
  content: 'MCLXXXIV-BC // ЛОКАЛЬНАЯ ПЕРЕДАЧА';
  position: relative;
  z-index: 2;
  color: #c9a95c;
  letter-spacing: 0.26em;
  margin-bottom: 1.1em;
}
#dossier.with-view #dossier-text {
  position: relative;
  z-index: 2;
  max-width: 62%;
  max-height: 68%;
  padding: 13px 18px 12px;
  background: rgba(4, 8, 10, 0.58);
  border-left: 1px solid rgba(224, 182, 74, 0.55);
  box-shadow: inset 0 0 24px rgba(0, 0, 0, 0.25);
  color: #dbe6df;
  text-shadow: 0 0 8px rgba(0, 0, 0, 0.85);
  font-size: clamp(11px, 1.15vw, 16px);
  line-height: 1.5;
}
#dossier.with-view #dossier-skip {
  position: relative;
  z-index: 2;
  color: #c9a95c;
}

/* ---------- menu ---------- */
#menu {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.86);
  z-index: 45;
  display: none;
  align-items: center;
  justify-content: center;
}
#menu.on { display: flex; }
#stage.menu-open #subtitles,
#stage.menu-open #hint { opacity: 0; }
.menu-panel {
  width: 74%;
  max-height: 78%;
  overflow: auto;
  border: 1px solid #3a4032;
  background: #080b07;
  padding: 1.6em 1.8em;
  box-shadow: 0 0 40px rgba(90, 140, 70, 0.12) inset;
}
.menu-title {
  color: #9ab183;
  letter-spacing: 0.25em;
  font-size: clamp(10px, 1vw, 13px);
  margin-bottom: 1.2em;
}
.menu-row {
  display: flex;
  justify-content: space-between;
  gap: 1em;
  padding: 0.32em 0.4em;
  color: #c8c2b0;
  font-size: clamp(9px, 0.92vw, 12px);
  border-bottom: 1px dotted #23271d;
}
.menu-row.locked { color: #4a4f43; }
.menu-row.available { cursor: pointer; }
.menu-row.available:hover { background: #12170e; color: #fff; }
.menu-row .date { color: #7d8a6b; }
.menu-foot {
  margin-top: 1.4em;
  color: #4e5b43;
  font-size: clamp(8px, 0.8vw, 11px);
  letter-spacing: 0.18em;
}

/* ---------- endcard ---------- */
#endcard {
  position: absolute;
  inset: 0;
  background: #000;
  color: #8f9c7c;
  z-index: 50;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2em;
  padding: 10%;
  text-align: center;
}
#endcard.on { display: flex; }

/* ---------- финальные титры ---------- */
#credits {
  position: absolute;
  inset: 0;
  background: #000;
  color: #7fd8ff;
  z-index: 60;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
  transition: opacity 1200ms ease;
}
#credits.on { opacity: 1; pointer-events: auto; }
#credits-scroll {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  padding: 0 8%;
  box-sizing: border-box;
  text-align: center;
  font-family: Consolas, "Courier New", monospace;
  font-size: clamp(15px, 1.7vw, 23px);
  line-height: 1.8;
  letter-spacing: 0.02em;
  text-shadow: 0 0 12px rgba(80, 190, 255, 0.22);
  will-change: transform;
}
#credits-scroll .credits-line {
  min-height: 1.8em;
  white-space: pre-wrap;
}
#credits-scroll .credits-line.title {
  font-size: 1.45em;
  letter-spacing: 0.14em;
  color: #b9f3ff;
  margin-bottom: 0.55em;
  text-shadow: 0 0 18px rgba(100, 210, 255, 0.32);
}
#credits a {
  color: #c8f6ff;
  text-decoration: underline;
  text-underline-offset: 0.18em;
  pointer-events: auto;
}
#credits a:hover { color: #fff; }

/* смерть героя: надпись по центру, без кнопок — уровень начинается сам */
#death {
  position: absolute;
  inset: 0;
  z-index: 46;
  display: none;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
#death.on { display: flex; }
#death span {
  font-size: clamp(18px, 3.4vw, 46px);
  letter-spacing: 0.28em;
  text-indent: 0.28em;
  color: #c0392b;
  text-shadow: 0 0 18px rgba(192, 57, 43, 0.45);
  opacity: 0;
  transition: opacity 900ms ease;
}
#death.on span { opacity: 1; }

#endcard-text {
  font-size: clamp(10px, 1vw, 14px);
  line-height: 1.7;
  white-space: pre-wrap;
  letter-spacing: 0.05em;
}
#restart, #continue {
  background: transparent;
  border: 1px solid #4d5a3f;
  color: #a9bd97;
  font-family: inherit;
  font-size: clamp(9px, 0.9vw, 12px);
  letter-spacing: 0.2em;
  padding: 0.8em 1.6em;
  cursor: pointer;
}
#restart:hover, #continue:hover { border-color: #c9a227; color: #e9e4d4; }
#restart { font-size: clamp(11px, 1.13vw, 15px); }
/* ---------- fatal ---------- */
#fatal {
  position: absolute;
  inset: 0;
  background: #050505;
  color: #d8c9a8;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 8% 10%;
  z-index: 60;
  box-sizing: border-box;
}
#fatal.on { display: flex; }
#fatal-text {
  font-family: "Consolas", "Courier New", monospace;
  font-size: clamp(11px, 1.05vw, 14px);
  line-height: 1.6;
  white-space: pre-wrap;
  margin: 0;
  color: #c9a227;
  text-shadow: 0 0 8px rgba(200, 160, 50, 0.2);
}
/* ---------- надпись на голограмме (уровень 5) ---------- */
#holoload {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  text-align: center;
  font-size: clamp(32px, 6.2vmin, 62px);
  letter-spacing: 0.18em;
  white-space: nowrap;
  text-transform: uppercase;
  color: #a9e2f2;
  text-shadow:
    0 0 6px rgba(120, 214, 238, 0.55),
    0 0 18px rgba(80, 170, 205, 0.35),
    0 0 34px rgba(60, 140, 175, 0.22);
  opacity: 0;
  display: none;
  pointer-events: none;
  z-index: 22;
}
#holoload.on { display: block; }
/* ---------- sound hint ---------- */
#sound-hint {
  position: absolute;
  top: 3%;
  right: 3%;
  color: #cfc4a8;
  font-size: clamp(8px, 0.78vw, 11px);
  letter-spacing: 0.14em;
  opacity: 0;
  transition: opacity 400ms ease;
  pointer-events: none;
  z-index: 24;
  text-shadow: 0 1px 3px #000;
}
#sound-hint.on { opacity: 0.8; }
/* ---------- start screen ---------- */
#start {
  position: absolute;
  inset: 0;
  background: #050505;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 1.6em;
  z-index: 41;
  padding: 8%;
  box-sizing: border-box;
}
#start.on { display: flex; }
#start-title {
  color: #ede3cc;
  font-family: "Consolas", "Courier New", monospace;
  font-size: clamp(40px, 6.4vw, 92px);
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: 0.22em;
  text-align: center;
  text-transform: uppercase;
  text-shadow:
    0 0 30px rgba(210, 170, 90, 0.34),
    0 2px 0 rgba(0, 0, 0, 0.85);
}
#start-button {
  margin-top: 0.6em;
  padding: 0.85em 2.8em;
  border: 1px solid #e4c789;
  background: #d8b06a;
  color: #16110a;
  font-family: "Consolas", "Courier New", monospace;
  font-size: clamp(14px, 1.5vw, 21px);
  letter-spacing: 0.24em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow:
    0 0 24px rgba(216, 176, 106, 0.22),
    inset 0 0 0 1px rgba(255, 245, 210, 0.25);
  transition: background 160ms ease, color 160ms ease, box-shadow 160ms ease;
}
#start-button:hover,
#start-button:focus-visible {
  background: #f0d59a;
  color: #090704;
  outline: none;
  box-shadow: 0 0 34px rgba(240, 213, 154, 0.4);
}

/* ---------- крупнее шрифты (+25%) и заметная подсказка ---------- */

#hint {
  right: 3%;
  bottom: 3.2%;
  color: #fffaf0;
  font-weight: 600;
  background: rgba(10, 7, 3, 0.88);
  border: 1px solid rgba(255, 214, 120, 0.45);
  border-radius: 2px;
  padding: 0.45em 0.9em;
  font-size: clamp(12px, 1.3vw, 17px);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-shadow: 0 1px 3px #000, 0 0 10px rgba(255, 210, 110, 0.4);
  box-shadow: 0 0 14px rgba(0, 0, 0, 0.55);
}
#hint.on { opacity: 1; animation: hintGlow 1.9s ease-in-out infinite; }

@keyframes hintGlow {
  0%, 100% { box-shadow: 0 0 10px rgba(0,0,0,.55); border-color: rgba(255, 214, 120, 0.4); }
  50% { box-shadow: 0 0 18px rgba(255, 210, 110, 0.3), 0 0 26px rgba(0,0,0,.6); border-color: rgba(255, 226, 150, 0.8); }
}

#speaker { font-size: clamp(11px, 1.19vw, 15px); }
#line { font-size: clamp(15px, 1.6vw, 22.5px); }

.choice { font-size: clamp(14px, 1.38vw, 19px); }
.choice .num { font-size: 0.92em; }

#dossier-text { font-size: clamp(11px, 1.28vw, 17.5px); }
#dossier-skip { font-size: clamp(10px, 1vw, 14px); }
#dossier::before { font-size: clamp(10px, 0.98vw, 14px); }

.menu-title { font-size: clamp(12.5px, 1.25vw, 16px); }
.menu-row { font-size: clamp(11px, 1.15vw, 15px); }
.menu-foot { font-size: clamp(10px, 1vw, 14px); }

#endcard-text { font-size: clamp(12.5px, 1.25vw, 17.5px); }
#restart, #continue { font-size: clamp(11px, 1.13vw, 15px); }

#sound-hint { font-size: clamp(10px, 0.98vw, 14px); }
#fatal-text { font-size: clamp(14px, 1.31vw, 17.5px); }
/* ---------- фрактальный сейф (уровень 2) ---------- */
#lock {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.62);
  z-index: 35;
}
#lock.on { display: flex; }
.lock-panel {
  width: min(76%, 430px);
  background: #070a06;
  border: 1px solid #3a4032;
  padding: 1.3em 1.5em 1.1em;
  box-shadow: 0 0 46px rgba(90, 140, 70, 0.16) inset;
  text-align: center;
}
.lock-title {
  color: #9ab183;
  letter-spacing: 0.28em;
  font-size: clamp(11px, 1.05vw, 14px);
  margin-bottom: 0.35em;
}
.lock-sub {
  color: #4e5b43;
  letter-spacing: 0.14em;
  font-size: clamp(8px, 0.78vw, 11px);
  margin-bottom: 1.1em;
}
#lock-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.35em;
  margin: 0 auto 1em;
  max-width: 300px;
}
.lock-cell {
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #2c3327;
  background: #0a0d08;
  color: #55604b;
  font-size: clamp(13px, 1.5vw, 20px);
  cursor: pointer;
  transition: color 140ms ease, border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
  user-select: none;
}
.lock-cell.lit {
  color: #f0e6c8;
  border-color: #c9a227;
  background: #1a1d12;
  box-shadow: 0 0 12px rgba(201, 162, 39, 0.55);
}
.lock-cell.sel {
  border-color: #7d8a6b;
  background: #12170e;
}
.lock-cell.ok {
  color: #a9bd97;
  border-color: #4e5b43;
  background: #0f140b;
}
.lock-cell.bad {
  color: #cf8a78;
  border-color: #7a3a30;
  background: #160b09;
}
#lock-status {
  color: #7d8a6b;
  letter-spacing: 0.2em;
  font-size: clamp(9px, 0.92vw, 12px);
  min-height: 1.4em;
}

/* ---------- интро перед первым уровнем ---------- */
/* Обложка на весь экран, медленный наезд до 1.15 и обратно, название сверху,
   мерцающее «НАЧАТЬ ИГРУ» и переключатель языка. Всё это живёт поверх
   чёрной сцены, пока игрок не начнёт игру. */
#intro {
  position: fixed;
  inset: 0;
  z-index: 55;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #000;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 700ms ease, visibility 700ms ease;
}
#intro.on {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
#intro.off {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
#intro-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  transform-origin: center;
  animation: introZoom 34s ease-in-out infinite;
  will-change: transform;
}
#intro-shade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(0,0,0,0.58) 0%, rgba(0,0,0,0.05) 32%, rgba(0,0,0,0.02) 55%, rgba(0,0,0,0.72) 100%),
    radial-gradient(ellipse at center, rgba(0,0,0,0) 38%, rgba(0,0,0,0.42) 100%);
}
#intro-content {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: clamp(32px, 8vh, 96px) 6vw clamp(28px, 7vh, 72px);
  box-sizing: border-box;
  pointer-events: none;
}
#intro-title {
  margin: 0;
  color: #ede3cc;
  font-family: "Consolas", "Courier New", monospace;
  font-size: clamp(24px, 4.2vw, 64px);
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: 0.3em;
  text-align: center;
  text-transform: uppercase;
  text-shadow:
    0 0 28px rgba(210, 170, 90, 0.35),
    0 2px 0 rgba(0, 0, 0, 0.85),
    0 0 2px #000;
}
#intro-synopsis.intro-synopsis-wait { visibility: hidden; }
#intro-synopsis {
  margin: clamp(14px, 2.2vh, 26px) 0 0;
  max-width: min(1000px, 90vw);
  color: #d6cdb8;
  font-family: "Consolas", "Courier New", monospace;
  font-size: 20px;
  font-weight: 400;
  line-height: 1.55;
  letter-spacing: 0.02em;
  text-align: center;
  text-shadow:
    0 2px 4px #000,
    0 0 14px #000,
    0 0 30px rgba(0, 0, 0, 0.85);
  opacity: 0.94;
}
#intro-actions {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(12px, 1.8vh, 22px);
  padding-bottom: clamp(14px, 3vh, 36px);
  pointer-events: auto;
  transition: opacity 220ms ease, visibility 220ms ease;
}
#intro.intro-lang-open #intro-actions {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
#intro-start {
  appearance: none;
  cursor: pointer;
  font-family: inherit;
  font-size: clamp(13px, 1.5vw, 21px);
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: #eadfbe;
  background: rgba(8, 12, 16, 0.34);
  border: 1px solid rgba(201, 162, 39, 0.55);
  padding: 0.8em 2.1em;
  animation: introBlink 2.4s ease-in-out infinite;
  transition: background 220ms ease, color 220ms ease, border-color 220ms ease, transform 220ms ease;
}
#intro-start:hover,
#intro-start:focus-visible {
  animation: none;
  opacity: 1;
  color: #fff;
  background: rgba(201, 162, 39, 0.16);
  border-color: #c9a227;
  outline: none;
  transform: translateY(-1px);
}
#intro-lang-modal {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6vw;
  background: rgba(0, 0, 0, 0.62);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 240ms ease, visibility 240ms ease;
}
#intro-lang-modal.on {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
.intro-lang-panel {
  width: min(90vw, 540px);
  box-sizing: border-box;
  padding: clamp(22px, 3.4vw, 40px) clamp(18px, 3vw, 36px);
  background: linear-gradient(180deg, rgba(10, 14, 18, 0.97), rgba(5, 8, 11, 0.97));
  border: 1px solid rgba(201, 162, 39, 0.5);
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.8), inset 0 0 30px rgba(201, 162, 39, 0.04);
  text-align: center;
}
.intro-lang-title {
  color: #e6d9a8;
  font-size: clamp(18px, 2.2vw, 30px);
  letter-spacing: 0.24em;
  line-height: 1.2;
  text-shadow: 0 0 18px rgba(201, 162, 39, 0.2);
}
.intro-lang-sub {
  margin-top: 0.55em;
  color: #8f8a7d;
  font-size: clamp(10px, 1.2vw, 15px);
  letter-spacing: 0.32em;
}
.intro-lang-options {
  display: flex;
  justify-content: center;
  gap: clamp(12px, 2vw, 24px);
  margin-top: clamp(20px, 3vw, 32px);
}
.intro-lang {
  appearance: none;
  cursor: pointer;
  min-width: 8.5em;
  padding: 0.8em 1.4em;
  color: #c9bfa6;
  background: rgba(8, 12, 16, 0.6);
  border: 1px solid rgba(201, 162, 39, 0.35);
  font: inherit;
  font-size: clamp(15px, 1.7vw, 22px);
  letter-spacing: 0.2em;
  transition: color 180ms ease, background 180ms ease, border-color 180ms ease;
}
.intro-lang:hover,
.intro-lang:focus-visible {
  color: #fff;
  background: rgba(201, 162, 39, 0.12);
  border-color: #c9a227;
  outline: none;
}
.intro-lang.on {
  color: #0b0d0f;
  background: #c9a227;
  border-color: #c9a227;
}
@keyframes introZoom {
  0% { transform: scale(1); }
  50% { transform: scale(1.15); }
  100% { transform: scale(1); }
}
@keyframes introBlink {
  0%, 100% { opacity: 0.38; }
  50% { opacity: 1; }
}
@media (max-width: 640px) {
  #intro-title { letter-spacing: 0.18em; }
  #intro-start { padding: 0.75em 1.4em; letter-spacing: 0.18em; }
}
@media (prefers-reduced-motion: reduce) {
  #intro-bg { animation: none; }
  #intro-start { animation: none; opacity: 1; }
}