/* ==========================================================
   KHAROS · FRONTIER WARS
   style.css — v0.5.3
   16-битная Sega Genesis-стилистика:
   ограниченная палитра, фаски, scanlines, пиксельный шрифт.
   ========================================================== */

/* ============ ОБЩЕЕ ============ */
* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%; height: 100%;
  background: #000; overflow: hidden;
  font-family: 'Press Start 2P', monospace;
  color: #f8f8f8;
  letter-spacing: 1px;
  -webkit-font-smoothing: none;
  image-rendering: pixelated;
}

.hidden { display: none !important; }

/* ============ ЗАГРУЗОЧНЫЙ ЭКРАН ============ */
#boot-screen {
  position: fixed; inset: 0;
  background: #000; z-index: 100;
  display: flex; align-items: center; justify-content: center;
}
#boot-canvas {
  width: 100%; height: 100%;
  max-width: 1024px; max-height: 640px;
  image-rendering: pixelated;
}

/* ============ МЕНЮ ============ */
#main-menu {
  position: fixed; inset: 0; z-index: 50;
  background: #000;
  display: flex; align-items: center; justify-content: center;
  padding: 20px; overflow-y: auto;
  /* Декоративные "звёзды" на фоне */
  background-image:
    radial-gradient(1px 1px at 20% 30%, #fff, transparent),
    radial-gradient(1px 1px at 60% 70%, #fff, transparent),
    radial-gradient(2px 2px at 80% 20%, #fff, transparent),
    radial-gradient(1px 1px at 40% 80%, #fff, transparent),
    radial-gradient(1px 1px at 90% 60%, #fff, transparent),
    radial-gradient(1px 1px at 10% 90%, #fff, transparent);
  background-size: 200px 200px;
  background-repeat: repeat;
}

.menu-panel {
  max-width: 820px; width: 100%;
  background: linear-gradient(180deg, #2a2a3a 0%, #1a1a2a 100%);
  border: 4px solid #000;
  box-shadow:
    inset 2px 2px 0 #5a5a7a,
    inset -2px -2px 0 #0a0a1a,
    0 0 40px rgba(0, 232, 216, 0.3);
  padding: 28px; text-align: center;
}

.game-title {
  font-size: 48px; color: #f8d800; letter-spacing: 6px;
  text-shadow: 4px 4px 0 #d82800, -2px -2px 0 #00e8d8;
  margin-bottom: 4px;
}
.game-subtitle {
  font-size: 14px; color: #00e8d8; letter-spacing: 8px;
  margin-bottom: 8px;
  text-shadow: 2px 2px 0 #000;
}
.game-version {
  font-size: 9px; color: #606070;
  letter-spacing: 2px; margin-bottom: 20px;
}

.lore-text {
  font-size: 10px; line-height: 1.8; color: #a0a0b0;
  margin-bottom: 24px; padding: 10px;
  background: #0a0a1a; border: 2px solid #3a3a5a;
}
.menu-label {
  font-size: 11px; color: #f8d800; letter-spacing: 4px;
  margin-bottom: 14px;
}

/* ============ КАРТОЧКИ ФРАКЦИЙ ============ */
.faction-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px; margin-bottom: 24px;
}
@media (max-width: 640px) {
  .faction-list { grid-template-columns: 1fr; }
}
.faction {
  background: linear-gradient(180deg, #3a3a5a 0%, #1a1a2a 100%);
  border: 3px solid #000;
  box-shadow:
    inset 2px 2px 0 #5a5a7a,
    inset -2px -2px 0 #0a0a1a;
  padding: 14px 10px;
  cursor: pointer;
  transition: transform .1s;
  text-align: center;
}
.faction:hover { transform: translateY(-2px); }
.faction.active {
  border-color: #f8d800;
  box-shadow:
    inset 2px 2px 0 #ffe040,
    inset -2px -2px 0 #805000,
    0 0 30px rgba(248, 216, 0, 0.5);
}
.fc-badge {
  width: 40px; height: 40px;
  margin: 0 auto 10px;
  border: 3px solid #000;
  box-shadow: inset -3px -3px 0 rgba(0, 0, 0, 0.4);
}
.fc-name {
  font-size: 11px; color: #f8f8f8;
  margin-bottom: 6px; letter-spacing: 2px;
}
.fc-desc {
  font-size: 8px; color: #a0a0b0; line-height: 1.6;
}
.fc-unique {
  margin-top: 8px; padding-top: 8px;
  border-top: 1px dashed #3a3a5a;
  font-size: 8px; color: #00e8d8;
}

/* ============ GENESIS-КНОПКИ ============ */
.genesis-btn {
  font-family: inherit;
  background: linear-gradient(180deg, #5a5a7a 0%, #2a2a3a 50%, #1a1a2a 100%);
  color: #f8f8f8;
  border: 3px solid #000;
  box-shadow:
    inset 2px 2px 0 #7a7a9a,
    inset -2px -2px 0 #0a0a1a;
  padding: 12px 22px;
  cursor: pointer;
  font-size: 12px; letter-spacing: 3px;
  transition: transform .05s;
}
.genesis-btn:hover:not(:disabled) {
  background: linear-gradient(180deg, #7a7a9a 0%, #3a3a4a 50%, #1a1a2a 100%);
}
.genesis-btn:active:not(:disabled) {
  transform: translate(1px, 1px);
  box-shadow:
    inset 1px 1px 0 #0a0a1a,
    inset -1px -1px 0 #7a7a9a;
}
.genesis-btn:disabled { opacity: .4; cursor: not-allowed; }
.genesis-btn.big { font-size: 14px; padding: 16px 40px; }
.genesis-btn.small { font-size: 9px; padding: 8px 12px; letter-spacing: 1px; }

.controls-hint {
  font-size: 8px; color: #606070;
  margin-top: 16px; line-height: 1.8;
  letter-spacing: 1px;
}
.controls-hint.small { font-size: 7px; margin-top: 8px; }

/* ============ ИГРОВОЙ ЭКРАН (FULLSCREEN) ============ */
#game-screen {
  position: fixed; inset: 0;
  background: #000;
  overflow: hidden;
}

/* Игровое поле растягивается на всё пространство */
#pixi-holder {
  position: absolute; inset: 0;
  background: #000;
  z-index: 1;
}
/* Канвас масштабируется через JS — сохраняя пропорции и центрируясь.
   Никакого object-fit, чтобы getBoundingClientRect совпадал с картинкой. */
#pixi-holder canvas:not(#minimap) {
  display: block;
  position: absolute;      /* координаты задаёт JS */
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* CRT-эффект поверх канваса */
#scanlines {
  position: absolute; inset: 0;
  pointer-events: none;
  z-index: 5;
  background: repeating-linear-gradient(
    180deg,
    rgba(0, 0, 0, 0) 0px,
    rgba(0, 0, 0, 0) 2px,
    rgba(0, 0, 0, 0.18) 3px,
    rgba(0, 0, 0, 0.18) 4px
  );
  mix-blend-mode: multiply;
}

/* ============ HUD (плавающая панель) ============ */
.hud {
  position: absolute;
  right: 12px; top: 12px; bottom: 12px;
  width: 260px;
  background: linear-gradient(180deg, rgba(42,42,58,0.94) 0%, rgba(26,26,42,0.97) 100%);
  border: 2px solid #000;
  box-shadow:
    inset 2px 2px 0 #5a5a7a,
    inset -2px -2px 0 #0a0a1a,
    4px 4px 0 rgba(0,0,0,0.6);
  padding: 10px;
  font-size: 9px;
  overflow-y: auto;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hud-header {
  text-align: center; color: #f8d800; font-size: 10px;
  letter-spacing: 2px; padding-bottom: 6px;
  border-bottom: 2px solid #3a3a5a;
}

.hud-resources,
.hud-power {
  display: flex; flex-direction: column; gap: 3px;
}
.hud-power { margin-bottom: 6px; }

.hud-row {
  display: flex; justify-content: space-between;
  color: #a0a0b0;
}
.hud-row b { color: #f8d800; }

.power-bar {
  height: 6px; background: #0a0a1a;
  border: 1px solid #3a3a5a;
}
.power-bar i {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, #00a800, #00e8d8);
  transition: width .3s;
}
.power-bar.low i {
  background: linear-gradient(90deg, #a80000, #d82800);
}

/* ============ ТАБЫ ============ */
.hud-tabs {
  display: flex; gap: 3px;
  margin-bottom: 4px;
}
.hud-tab {
  flex: 1;
  font-family: inherit;
  font-size: 8px; letter-spacing: 1px;
  padding: 6px 4px;
  color: #a0a0b0;
  background: linear-gradient(180deg, #3a3a5a 0%, #1a1a2a 100%);
  border: 2px solid #000;
  box-shadow:
    inset 1px 1px 0 #5a5a7a,
    inset -1px -1px 0 #0a0a1a;
  cursor: pointer;
  transition: .1s;
  width: auto; margin: 0;
  justify-content: center;
}
.hud-tab:hover {
  background: linear-gradient(180deg, #4a4a6a 0%, #2a2a3a 100%);
}
.hud-tab.active {
  color: #f8d800;
  background: linear-gradient(180deg, #5a5a7a 0%, #3a3a4a 100%);
  border-color: #f8d800;
}

.hud-tab-content {
  display: flex; flex-direction: column; gap: 3px;
  flex-shrink: 0;
}

/* ============ КНОПКИ ПОСТРОЙКИ ============ */
.hud-label {
  font-size: 8px; color: #00e8d8; letter-spacing: 2px;
  padding-bottom: 2px; margin-top: 4px;
  border-bottom: 1px dashed #3a3a5a;
}

#buildButtons,
#infButtons,
#vehButtons {
  display: flex; flex-direction: column; gap: 3px;
}

#buildButtons button,
#infButtons button,
#vehButtons button {
  font-family: inherit;
  display: flex; justify-content: space-between;
  align-items: center;
  background: linear-gradient(180deg, #3a3a5a 0%, #1a1a2a 100%);
  color: #f8f8f8;
  border: 2px solid #000;
  box-shadow:
    inset 1px 1px 0 #5a5a7a,
    inset -1px -1px 0 #0a0a1a;
  padding: 6px 8px;
  font-size: 8px;
  cursor: pointer;
  letter-spacing: 1px;
  text-align: left;
  position: relative;
  transition: background .1s;
}
#buildButtons button:hover:not(:disabled),
#infButtons button:hover:not(:disabled),
#vehButtons button:hover:not(:disabled) {
  background: linear-gradient(180deg, #5a5a7a 0%, #2a2a3a 100%);
}
#buildButtons button span,
#infButtons button span,
#vehButtons button span { color: #f8d800; }

/* --- Активное здание (ждёт постановки) --- */
#buildButtons button.active {
  background: linear-gradient(180deg, #f8d800 0%, #a08000 100%) !important;
  border-color: #f8d800;
  color: #000;
}
#buildButtons button.active span { color: #503000; }

/* --- Готовое, но не поставленное здание --- */
#buildButtons button.ready {
  border-color: #00e8d8;
  animation: pulseReady 1.2s ease-in-out infinite;
}
@keyframes pulseReady {
  0%, 100% { box-shadow: inset 1px 1px 0 #5a5a7a, inset -1px -1px 0 #0a0a1a, 0 0 4px #00e8d8; }
  50%      { box-shadow: inset 1px 1px 0 #5a5a7a, inset -1px -1px 0 #0a0a1a, 0 0 14px #00e8d8; }
}

/* --- Строится сейчас (прогресс через CSS-переменную --progress) --- */
#buildButtons button.building {
  background: linear-gradient(
    to right,
    #0058f8 0%,
    #0058f8 var(--progress, 0%),
    #1a1a2a var(--progress, 0%),
    #1a1a2a 100%
  ) !important;
  color: #fff;
}
#buildButtons button.building span { color: #f8d800; }

/* --- Стоит в очереди, но не первый --- */
#buildButtons button.queued {
  border-color: #f8d800;
  border-style: dashed;
  color: #d0d0d0;
}

/* ============ ДЕЙСТВИЯ ВНИЗУ HUD ============ */
.hud-actions {
  display: flex; gap: 4px;
  margin-top: auto;
  padding-top: 8px;
}
.hud-actions .genesis-btn { flex: 1; }

.hud-version {
  text-align: right;
  font-size: 7px;
  color: #404050;
  letter-spacing: 1px;
}

/* ============ МИНИКАРТА (левый верх) ============ */
/* Миникарта внутри HUD, над всеми кнопками */
#minimap-wrapper {
  align-self: center;
  padding: 2px;
  border: 2px solid #000;
  background: #000;
  box-shadow:
    inset 2px 2px 0 #5a5a7a,
    inset -2px -2px 0 #0a0a1a;
  flex-shrink: 0;
}
#minimap {
  display: block;
  image-rendering: pixelated;
}

/* ============ СТАТУС (левый низ) ============ */
#status {
  position: absolute;
  left: 12px; bottom: 12px;
  right: calc(260px + 24px + 12px);   /* ширина HUD + отступ */
  padding: 8px 12px;
  background: rgba(10, 10, 26, 0.92);
  border: 2px solid #000;
  box-shadow:
    inset 1px 1px 0 #3a3a5a,
    inset -1px -1px 0 #0a0a1a;
  color: #f8d800;
  font-size: 8px; letter-spacing: 1px;
  line-height: 1.6;
  min-height: 22px;
  z-index: 10;
  word-break: break-word;
}

/* ==========================================================
   ПАНЕЛЬ СПОСОБНОСТЕЙ ФРАКЦИИ (v0.5.0)
   ========================================================== */
.hud-abilities {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  margin-bottom: 6px;
}

.ability-btn {
  position: relative;
  padding: 6px 4px;
  background: linear-gradient(180deg, #3a3a5a 0%, #1a1a2a 100%);
  border: 2px solid #000;
  box-shadow: inset 1px 1px 0 #5a5a7a, inset -1px -1px 0 #0a0a1a;
  color: #f8f8f8;
  cursor: pointer;
  font-family: inherit;
  font-size: 8px;
  text-align: center;
  width: 100%;
  min-height: 52px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: background .12s;
}
.ability-btn:hover:not(.locked):not(.cooldown) {
  background: linear-gradient(180deg, #5a5a7a 0%, #2a2a3a 100%);
}
.ability-btn.locked {
  opacity: 0.3;
  cursor: not-allowed;
}
.ability-btn.cooldown {
  background: linear-gradient(180deg, #2a2a3a 0%, #0a0a1a 100%);
  color: #606070;
  cursor: not-allowed;
}
.ability-btn.active {
  border-color: #f8d800;
  box-shadow:
    inset 1px 1px 0 #5a5a7a,
    0 0 12px #f8d800;
}
.ability-icon {
  font-size: 18px;
  display: block;
  margin-bottom: 2px;
  line-height: 1;
}
.ability-cd {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  font-size: 14px;
  color: #f8d800;
  font-weight: bold;
}
.ability-hotkey {
  position: absolute;
  top: 2px;
  right: 4px;
  font-size: 7px;
  color: #a0a0b0;
}

/* ============ ВЫБОР КАРТ (v0.5.3) ============ */
.genesis-select {
  font-family: inherit;
  background: linear-gradient(180deg, #3a3a5a 0%, #1a1a2a 100%);
  color: #f8f8f8;
  border: 3px solid #000;
  box-shadow: inset 2px 2px 0 #5a5a7a, inset -2px -2px 0 #0a0a1a;
  padding: 8px 12px;
  font-size: 11px;
  letter-spacing: 2px;
  cursor: pointer;
  min-width: 240px;
  margin-bottom: 16px;
}
.genesis-select:focus {
  outline: 2px solid #f8d800;
  outline-offset: 2px;
}
