@font-face {
  font-family: 'WebPlus IBM CGA';
  src: url('WebPlus_IBM_CGA.woff') format('woff');
  font-weight: normal;
  font-style: normal;
  font-display: block; /* не показывать текст, пока шрифт не загружен */
}

:root {
  --bg: #0f0a00;               /* тёмно-коричневый фон */
  --ink: #ffa500;              /* оранжевый цвет текста */
  --font-size: 24px;
  --line-height: 1;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: 'WebPlus IBM CGA', 'VT323', 'Courier New', monospace;
  font-size: var(--font-size);
  line-height: var(--line-height);
  text-shadow: 0 0 1px rgba(255, 165, 0, 0.2);
}

#terminal {
  position: relative;
  width: 100%;
  height: 100%;
  padding: 0;               /* убираем отступы, чтобы центрирование было по всей ширине */
  background: var(--bg);
  overflow: hidden;
  white-space: pre;
  display: flex;
  justify-content: center;   /* горизонтальное центрирование */
  align-items: flex-start;   /* вертикально сверху (можно заменить на center, если нужно и вертикальное центрирование) */
}

/* Контейнер, который масштабируется через transform в script.js */
#viewport {
  position: relative;
  transform-origin: top left;
}

#viewport canvas {
  display: block;
  image-rendering: pixelated;
}

/* Слой для изображений (SVG) */
.image-overlay {
  --corner-size: 8px;
  position: absolute;
  z-index: 50;
  overflow: hidden;
  pointer-events: none;
  background: var(--ink);
  clip-path: polygon(
    0 var(--corner-size),
    var(--corner-size) 0,
    calc(100% - var(--corner-size)) 0,
    100% var(--corner-size),
    100% calc(100% - var(--corner-size)),
    calc(100% - var(--corner-size)) 100%,
    var(--corner-size) 100%,
    0 calc(100% - var(--corner-size))
  );
}

.image-overlay svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* Кликабельные ссылки, создаваемые в терминале */
.link-overlay {
  position: absolute;
  cursor: pointer;
  z-index: 60;
  background: transparent;
  border-bottom: 1px solid var(--ink);
  transition: background 0.15s ease;
}

.link-overlay:hover {
  background: rgba(255, 165, 0, 0.2);
}

/* Экран загрузки */
#boot-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh; /* динамическая высота для мобильных */
  background: #0f0a00;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  /* Поднимаем сообщение выше центра */
  padding-bottom: 15vh; /* сдвиг вверх на 15% высоты экрана */
  z-index: 9999;
  transition: opacity 0.4s ease;
  pointer-events: none;
  font-family: 'WebPlus IBM CGA', 'VT323', 'Courier New', monospace;
  color: #ffa500;
  transform: translateZ(0);
}

#boot-screen.hidden {
  opacity: 0;
  pointer-events: none;
}

.boot-logo {
  font-size: 48px;
  margin-bottom: 20px;
  text-align: center;
}

.boot-loading {
  font-size: 24px;
  text-align: center;
}

/* Поля ввода, создаваемые в терминале */
.terminal-input {
  position: absolute;
  background: rgba(255, 165, 0, 0.05);
  border: 2px solid #ffa500;
  color: #ffa500;
  font-family: 'WebPlus IBM CGA', 'VT323', monospace;
  font-size: var(--font-size);
  line-height: var(--line-height);
  outline: none;
  z-index: 65;
  pointer-events: auto;
  padding: 0 4px;
  text-shadow: 0 0 1px rgba(255, 165, 0, 0.2);
}

.terminal-input:focus {
  border-color: #ffffff;
  background: rgba(255, 165, 0, 0.1);
}

/* Контейнер для поля ввода с возможностью прокрутки стрелками */
.terminal-input-container {
  position: absolute;
  z-index: 65;
  pointer-events: auto;
}

/* Стрелки прокрутки внутри поля ввода */
.terminal-scroll-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  cursor: pointer;
  font-family: 'WebPlus IBM CGA', 'VT323', monospace;
  font-size: 24px;
  color: #000;
  background: #ffa500;
  padding: 0 2px;
  user-select: none;
  z-index: 70;
  line-height: 1;
  opacity: 1;
  transition: opacity 0.2s;
}

.terminal-scroll-arrow-left {
  left: 0;
}

.terminal-scroll-arrow-right {
  right: 0;
}

/* Кнопки, создаваемые в терминале */
.terminal-button {
  position: absolute;
  background: transparent;
  border: 2px solid #ffa500;
  color: #ffa500;
  font-family: 'WebPlus IBM CGA', 'VT323', monospace;
  font-size: var(--font-size);
  line-height: var(--line-height);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 65;
  pointer-events: auto;
  padding: 0 6px;
  transition: background 0.15s ease;
}

.terminal-button:hover {
  background: rgba(255, 165, 0, 0.2);
}

/* Старые вспомогательные классы */
.terminal-row {
  height: calc(var(--font-size) * var(--line-height));
  line-height: var(--line-height);
}

/* Цвета текста */
.fg-black { color: #000000; }
.fg-red { color: #ff5555; }
.fg-green { color: #55ff55; }
.fg-yellow { color: #ffff55; }
.fg-blue { color: #5555ff; }
.fg-magenta { color: #ff55ff; }
.fg-cyan { color: #55ffff; }
.fg-white { color: var(--ink); }

/* Цвета фона */
.bg-black { background-color: var(--bg); }
.bg-red { background-color: #550000; }
.bg-green { background-color: #005500; }
.bg-yellow { background-color: #555500; }
.bg-blue { background-color: #000055; }
.bg-magenta { background-color: #550055; }
.bg-cyan { background-color: #005555; }
.bg-white { background-color: var(--ink); }

.bold { font-weight: bold; }

.cursor-visible {
  background: var(--ink);
  color: var(--bg);
}

.menu-item {
  cursor: pointer;
  text-decoration: underline;
}
.menu-item:hover {
  background: var(--ink);
  color: var(--bg);
}

/* Остальные классы */
.clickable-link {
  position: absolute;
  cursor: pointer;
  background: transparent;
  z-index: 60;
}

.clickable-link:hover {
  background: var(--ink);
  opacity: 0.2;
}

.big-text-container {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 40;
  pointer-events: none;
}

.big-char-sprite {
  position: absolute;
  background-repeat: no-repeat;
  background-position: left top;
  background-size: 100% 100%;
  pointer-events: none;
}

.cell {
  display: inline-block;
  background-repeat: no-repeat;
  background-position: left top;
  background-size: 100% 100%;
}