/* styles/base.css
 * База: html/body, верхняя панель, faction badge, тосты,
 * каркас модалки, fatal, gameover.
 * Порядок подключения: первым.
 */

html, body {
  margin: 0; padding: 0; overflow: hidden;
  background: #000; height: 100%;
  user-select: none;
  /* Никаких засечек: в миниатюре HUD они хуже читаются. Наследуется
   * всем текстом, включая кнопки, поля и подписи без своего font-family. */
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  /* Верхний ряд: три колонки, как нижний ряд дока. Это границы, а не
   * растяжение: панель стоит своего размера, но не шире своей колонки. */
  --top-slot: 15%;
  --top-slot-mid: 70%;
}

button, input, select, textarea {
  font-family: inherit;
}

/* Canvas — единственный элемент, у которого отключаем браузерные
 * тач-жесты (pinch-zoom страницы, скролл). Панели и модалки — не canvas,
 * они наследуют auto и скроллятся как обычно.
 * Нужен для camera-touch.js (двухпальцевые жесты). */
canvas {
  display: block;
  touch-action: none;
}

/* ===== Верхняя левая панель кнопок ===== */
#top-bar-left {
  position: fixed; top: 12px; left: 12px;
  display: flex; gap: 6px;
  /* Левая колонка верхнего ряда: 15 % минус отступ. Кнопки переносятся,
   * а не наезжают на часы по центру. */
  flex-wrap: wrap;
  max-width: calc(var(--top-slot, 15%) - 12px);
  z-index: 70;
}
.top-btn {
  width: 34px; height: 34px;
  background: rgba(20, 20, 25, 0.85);
  border: 2px solid #5a4a2a; border-radius: 6px;
  color: #f0e0b0; font-size: 16px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.1s, border-color 0.1s;
  position: relative;
}
.top-btn:hover { background: #333; border-color: #888; }
.top-btn.active { background: #2a3a4a; border-color: #5a7a9a; color: #fff; }
.top-btn-badge {
  position: absolute; top: -5px; right: -5px;
  min-width: 15px; height: 15px; padding: 0 3px;
  box-sizing: border-box;
  border-radius: 8px;
  background: #b85636; color: #fff;
  border: 1px solid #1a1a1a;
  font: 700 9px/13px sans-serif;
  text-align: center;
}
.top-btn-badge[hidden] { display: none; }

/* ===== Тосты ===== */
#toast {
  position: fixed; bottom: 20px; left: 50%;
  transform: translateX(-50%);
  padding: 8px 16px;
  background: rgba(20, 20, 25, 0.92);
  border: 2px solid #5a4a2a; border-radius: 8px;
  color: #f0e0b0; font-family: sans-serif; font-size: 13px;
  z-index: 80; max-width: calc(var(--ui-vw, 100vw) * 0.6); text-align: center;
  display: none; pointer-events: none;
  box-shadow: 0 2px 12px rgba(0,0,0,0.8);
}
#toast.fatal { border-color: #a04040; color: #ff8866; }

/* ===== Каркас модалки ===== */
#modal-root {
  position: fixed; inset: 0; z-index: 110;
  display: none; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.6);
}
#modal-root.open { display: flex; }
.modal {
  min-width: min(380px, 100%);
  max-width: min(560px, calc(var(--ui-vw, 100vw) - 24px));
  max-height: calc(var(--ui-vh, 100vh) * 0.85);
  background: rgba(20, 20, 25, 0.98);
  border: 2px solid #555; border-radius: 8px;
  padding: 16px; color: #ddd; font-family: sans-serif;
  display: flex; flex-direction: column;
  box-shadow: 0 4px 20px rgba(0,0,0,0.9);
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  font-weight: bold; font-size: 16px;
  border-bottom: 1px solid #444; padding-bottom: 8px; margin-bottom: 12px;
}
.modal-close {
  background: none; border: none; color: #aaa; font-size: 22px;
  cursor: pointer; line-height: 1; padding: 0 0 0 8px;
}
.modal-close:hover { color: #fff; }
.modal-body { overflow-y: auto; max-height: calc(var(--ui-vh, 100vh) * 0.65); padding-right: 4px; }

/* ===== Fatal / gameover ===== */
#gameover {
  position: fixed; inset: 0; background: rgba(80, 0, 0, 0.85); color: #fff;
  display: none; align-items: center; justify-content: center;
  font-family: sans-serif; font-size: 32px; flex-direction: column; z-index: 10;
}
#fatal {
  position: fixed; inset: 0; display: none; z-index: 30000;
  background: rgba(10, 10, 12, 0.94); color: #eee;
  font-family: ui-monospace, monospace; font-size: 14px; line-height: 1.65;
  padding: 40px; box-sizing: border-box; overflow: auto;
}
#fatal b { color: #ff8866; font-size: 16px; }
#fatal code { color: #8ecbff; }
#fatal ul { margin: 10px 0 0 0; padding-left: 22px; }