/* style.css — Iron Banner: тёмная тема, уголь/охра/бордо, акцент — золото. */

:root {
  /* Палитра */
  --bg: #14100e;
  --bg-2: #1c1613;
  --panel: #241c17;
  --panel-2: #2c221c;
  --line: #3d2e23;
  --text: #e9ddcf;
  --muted: #a08d79;
  --gold: #d9a441;
  --gold-dim: #9c7630;
  --rust: #c1613a;
  --blood: #8c2f2f;
  --ok: #7fa86b;

  /* Шрифты */
  --font-title: Georgia, 'Times New Roman', 'PT Serif', serif;
  --font-ui: 'Segoe UI', system-ui, -apple-system, Arial, sans-serif;

  /* Тени и радиусы */
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(217, 164, 65, 0.08), transparent 60%),
    linear-gradient(180deg, var(--bg-2) 0%, var(--bg) 100%);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
}

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- Заголовки ---------- */

h1,
h2,
h3 {
  font-family: var(--font-title);
  color: var(--gold);
  margin: 0 0 0.4em;
  letter-spacing: 0.02em;
}

h1 {
  font-size: 2.4rem;
}

h2 {
  font-size: 1.6rem;
}

h3 {
  font-size: 1.15rem;
  color: var(--text);
}

/* ---------- Экраны ---------- */

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  gap: 10px;
  min-width: 320px;
}

.screen-title {
  margin: 0;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.6);
}

.screen-subtitle {
  color: var(--muted);
  margin: 0 0 12px;
  text-align: center;
}

.screen-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin-top: 8px;
}

.stub-banner {
  font-size: 4rem;
  line-height: 1;
  filter: drop-shadow(0 6px 18px rgba(217, 164, 65, 0.35));
  animation: float 3.2s ease-in-out infinite;
}

@keyframes float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

/* ---------- Панели ---------- */

.panel {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.panel-title {
  font-family: var(--font-title);
  color: var(--gold);
  font-size: 1.05rem;
  margin: 0 0 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ---------- Кнопки ---------- */

.btn {
  font-family: var(--font-ui);
  font-size: 0.95rem;
  color: var(--text);
  background: linear-gradient(180deg, var(--panel-2), var(--bg-2));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 20px;
  cursor: pointer;
  transition:
    transform 0.12s ease,
    border-color 0.12s ease,
    background 0.12s ease;
}

.btn:hover {
  border-color: var(--gold-dim);
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: linear-gradient(180deg, #e0b054, #b8862f);
  border-color: #8a6423;
  color: #241a08;
  font-weight: 600;
}

.btn-primary:hover {
  border-color: var(--gold);
  background: linear-gradient(180deg, #eec272, #c69437);
}

.btn-danger {
  border-color: var(--blood);
  color: #e8b7b7;
}

.btn-danger:hover {
  border-color: #c04a4a;
  background: linear-gradient(180deg, #4a2222, #2c1616);
}

/* ---------- Мелочи ---------- */

.muted {
  color: var(--muted);
}

.gold {
  color: var(--gold);
}

.hidden {
  display: none !important;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--bg-2);
}

::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 6px;
}

/* ---------- Главное меню ---------- */

.menu-screen {
  justify-content: center;
  gap: 6px;
}

.menu-crest {
  width: 92px;
  height: 92px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.8rem;
  color: var(--gold);
  background: radial-gradient(circle at 50% 35%, rgba(217, 164, 65, 0.22), rgba(0, 0, 0, 0.25));
  border: 2px solid var(--gold-dim);
  border-radius: 50%;
  box-shadow:
    0 0 32px rgba(217, 164, 65, 0.25),
    var(--shadow);
  margin-bottom: 10px;
  animation: float 3.6s ease-in-out infinite;
}

.menu-title {
  font-size: 3.2rem;
  letter-spacing: 0.14em;
  background: linear-gradient(180deg, #f2d188, #c1913c 55%, #8a6423);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 320px;
  max-width: 90vw;
  margin-top: 14px;
}

.btn-big {
  padding: 14px 22px;
  font-size: 1.05rem;
}

.menu-footer {
  display: flex;
  gap: 18px;
  margin-top: 26px;
  font-size: 0.85rem;
}

/* ---------- Модальные окна ---------- */

.modal-layer {
  position: fixed;
  inset: 0;
  background: rgba(10, 7, 5, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(2px);
}

.modal-box {
  width: 460px;
  max-width: 92vw;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--gold-dim);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}

.modal-title {
  margin-bottom: 8px;
}

.modal-body {
  color: var(--muted);
  margin: 0 0 14px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 18px;
}

/* ---------- Настройки ---------- */

.setting-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.setting-row:last-of-type {
  border-bottom: none;
}

.setting-label {
  flex: 1;
  color: var(--text);
}

.setting-value {
  color: var(--gold);
  min-width: 42px;
  text-align: right;
}

.setting-input {
  accent-color: var(--gold);
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 8px;
}

.setting-danger {
  justify-content: flex-start;
  margin-top: 8px;
}

/* ---------- Сцена 1: сюжетная вставка ---------- */

.intro-screen {
  position: relative;
  justify-content: flex-end;
  overflow: hidden;
  padding: 0;
  cursor: pointer;
}

/* Ночное небо */
.intro-sky {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(900px 420px at 75% 12%, rgba(217, 164, 65, 0.16), transparent 65%),
    linear-gradient(180deg, #221a2b 0%, #16121c 45%, #0d0a10 100%);
  z-index: 0;
}

/* Силуэт крепости */
.intro-fortress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 26%;
  height: 34%;
  z-index: 1;
  background:
    linear-gradient(180deg, #0a0810 0%, #120e16 100%);
  clip-path: polygon(
    0% 100%, 0% 55%, 6% 55%, 6% 30%, 10% 30%, 10% 55%, 18% 55%, 18% 42%, 24% 42%, 24% 20%,
    27% 20%, 27% 42%, 34% 42%, 34% 55%, 42% 55%, 42% 25%, 45% 25%, 45% 8%, 48% 8%, 48% 25%,
    52% 25%, 52% 55%, 60% 55%, 60% 38%, 66% 38%, 66% 22%, 69% 22%, 69% 38%, 76% 38%, 76% 55%,
    84% 55%, 84% 34%, 88% 34%, 88% 55%, 100% 55%, 100% 100%
  );
  opacity: 0.9;
}

.intro-skip {
  position: absolute;
  top: 18px;
  right: 20px;
  z-index: 5;
}

.intro-dialog {
  position: relative;
  z-index: 3;
  display: flex;
  gap: 18px;
  align-items: flex-start;
  width: min(880px, 92vw);
  margin: 0 auto 42px;
  padding: 20px 24px;
  background: linear-gradient(180deg, rgba(30, 23, 19, 0.96), rgba(20, 15, 12, 0.96));
  border: 1px solid var(--gold-dim);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  animation: dialog-in 0.35s ease;
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.intro-portrait {
  flex: 0 0 84px;
  width: 84px;
  height: 84px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-title);
  font-size: 2.1rem;
  color: #f4e7d2;
  border: 2px solid rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  background: linear-gradient(180deg, #5c5347, rgba(0, 0, 0, 0.4));
  box-shadow: var(--shadow);
}

.intro-dialog-body {
  flex: 1;
}

.intro-speaker {
  font-family: var(--font-title);
  color: var(--gold);
  font-size: 1.05rem;
  margin-bottom: 6px;
  letter-spacing: 0.03em;
}

.intro-text {
  font-size: 1.12rem;
  line-height: 1.65;
  min-height: 5.2em;
  color: var(--text);
}

.intro-hint {
  margin-top: 10px;
  font-size: 0.82rem;
  text-align: right;
}

/* ---------- Юниты (armySlot): база + слои экипировки ---------- */

.unit {
  --role-color: #8a97a8;
  position: relative;
  width: 40px;
  height: 48px;
  flex: 0 0 auto;
}

.unit-sm {
  width: 26px;
  height: 32px;
  transform: scale(0.9);
}

.unit-lg {
  width: 84px;
  height: 104px;
}

.unit-body {
  position: absolute;
  left: 22%;
  right: 22%;
  bottom: 6%;
  height: 52%;
  background: linear-gradient(180deg, var(--role-color), rgba(0, 0, 0, 0.55));
  border: 1px solid rgba(0, 0, 0, 0.45);
  border-radius: 6px 6px 3px 3px;
}

.unit-head {
  position: absolute;
  left: 50%;
  top: 12%;
  width: 34%;
  height: 28%;
  transform: translateX(-50%);
  background: #d9b48c;
  border: 1px solid rgba(0, 0, 0, 0.45);
  border-radius: 50% 50% 42% 42%;
}

.unit-mark {
  position: absolute;
  left: 50%;
  bottom: 8%;
  transform: translateX(-50%);
  font-family: var(--font-title);
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.9);
  z-index: 3;
}

.unit-lg .unit-mark {
  font-size: 1.4rem;
}

/* Слои экипировки */
.unit-layer {
  position: absolute;
  z-index: 2;
  pointer-events: none;
}

/* Шлем: полусфера на голове */
.unit-layer-helmet {
  left: 50%;
  top: 6%;
  width: 44%;
  height: 26%;
  transform: translateX(-50%);
  background: linear-gradient(180deg, #b9c2cc, #6c7784);
  border: 1px solid #2d343c;
  border-radius: 50% 50% 18% 18%;
}

/* Копьё: древко справа от юнита */
.unit-layer-spear {
  right: -6%;
  top: 2%;
  width: 8%;
  height: 82%;
  background: linear-gradient(180deg, #9a7442, #6b4f2c);
  border-radius: 2px;
  transform: rotate(6deg);
}

.unit-layer-spear::after {
  content: '';
  position: absolute;
  top: -8%;
  left: 50%;
  transform: translateX(-50%);
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 12px solid #c6ced6;
}

/* Броня: плащ-нагрудник поверх тела */
.unit-layer-armor {
  left: 14%;
  right: 14%;
  bottom: 4%;
  height: 58%;
  background: linear-gradient(180deg, #7d5a3c, #4a3421);
  border: 1px solid #2c1e12;
  border-radius: 7px 7px 3px 3px;
  opacity: 0.95;
}

/* Щит: слева */
.unit-layer-shield {
  left: -14%;
  bottom: 14%;
  width: 36%;
  height: 46%;
  background: linear-gradient(180deg, #8a97a8, #4c5763);
  border: 1px solid #2d343c;
  border-radius: 40% 40% 22% 22%;
}

/* Капюшон поддержки */
.unit-layer-hood {
  left: 50%;
  top: 6%;
  width: 46%;
  height: 34%;
  transform: translateX(-50%);
  background: linear-gradient(180deg, #5f8a70, #33513f);
  border: 1px solid #22342a;
  border-radius: 50% 50% 30% 30%;
}

/* Знамя: древко с флагом */
.unit-layer-banner {
  right: -10%;
  top: -6%;
  width: 7%;
  height: 92%;
  background: linear-gradient(180deg, #9a7442, #6b4f2c);
  border-radius: 2px;
}

.unit-layer-banner::after {
  content: '';
  position: absolute;
  top: 0;
  left: 100%;
  width: 180%;
  height: 34%;
  background: linear-gradient(180deg, var(--gold), var(--gold-dim));
  clip-path: polygon(0 0, 100% 0, 82% 50%, 100% 100%, 0 100%);
}

/* ---------- Стак-карточки ---------- */

.stack-card {
  --role-color: #8a97a8;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-left: 3px solid var(--role-color);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stack-card-clickable {
  cursor: pointer;
  transition: border-color 0.12s ease, transform 0.12s ease;
}

.stack-card-clickable:hover {
  border-color: var(--gold-dim);
  transform: translateY(-1px);
}

.stack-card-preview {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  align-items: flex-end;
  min-height: 34px;
}

.stack-card-name {
  font-family: var(--font-title);
  color: var(--text);
}

.stack-card-stats {
  font-size: 0.82rem;
}

/* ---------- Сцена 2: редактор полководца ---------- */

.creator-screen {
  justify-content: flex-start;
  padding-top: 26px;
}

.creator-grid {
  display: grid;
  grid-template-columns: minmax(200px, 260px) minmax(320px, 1fr) minmax(280px, 340px);
  gap: 16px;
  width: min(1180px, 96vw);
  align-items: start;
}

.creator-preview-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.creator-preview-wrap {
  display: flex;
  justify-content: center;
  padding: 12px;
  background: rgba(0, 0, 0, 0.22);
  border-radius: 8px;
}

.creator-name {
  width: 100%;
  padding: 9px 12px;
  font-size: 0.98rem;
}

.class-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.class-card {
  --class-color: var(--gold);
  border: 1px solid var(--line);
  border-left: 3px solid var(--class-color);
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
  background: rgba(0, 0, 0, 0.18);
  transition: border-color 0.12s ease, background 0.12s ease;
}

.class-card:hover {
  border-color: var(--gold-dim);
}

.class-card-selected {
  background: rgba(217, 164, 65, 0.12);
  border-color: var(--gold);
  box-shadow: 0 0 0 1px var(--gold-dim) inset;
}

.class-card-name {
  font-family: var(--font-title);
  font-size: 1.1rem;
  color: var(--text);
}

.class-card-role {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.class-card-desc {
  margin-top: 6px;
  font-size: 0.9rem;
}

.class-card-passive {
  margin-top: 6px;
  font-size: 0.82rem;
  color: var(--gold);
}

.creator-points {
  font-size: 1.02rem;
  margin-bottom: 8px;
}

.stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.stat-label {
  color: var(--text);
}

.stat-value-box {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stat-value {
  min-width: 26px;
  text-align: center;
  font-size: 1.1rem;
  color: var(--text);
}

.stat-bonus {
  min-width: 34px;
  font-size: 0.85rem;
}

.stat-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: 1.15rem;
  line-height: 1;
}

.creator-note {
  font-size: 0.82rem;
  margin: 12px 0;
}

.creator-start {
  width: 100%;
}

/* ---------- Сцена 3: дорожная карта ---------- */

.map-screen {
  justify-content: flex-start;
  padding-top: 18px;
  gap: 14px;
}

.map-topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  width: min(1100px, 96vw);
  padding: 12px 18px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.map-topbar-title {
  font-family: var(--font-title);
  color: var(--gold);
  font-size: 1.15rem;
  white-space: nowrap;
}

.map-topbar-stats {
  flex: 1;
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  font-size: 0.9rem;
}

.map-graph-wrap {
  width: min(1100px, 96vw);
  background:
    radial-gradient(700px 320px at 50% 30%, rgba(217, 164, 65, 0.07), transparent 70%),
    linear-gradient(180deg, var(--bg-2), var(--bg));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 8px;
}

.map-graph {
  width: 100%;
  height: auto;
  display: block;
}

.map-edge {
  fill: none;
  stroke: var(--line);
  stroke-width: 2.5;
}

.map-edge-active {
  stroke: var(--gold);
  stroke-dasharray: 8 6;
  animation: edge-flow 1.2s linear infinite;
}

@keyframes edge-flow {
  to {
    stroke-dashoffset: -14;
  }
}

.map-node {
  cursor: default;
}

.map-node-available {
  cursor: pointer;
}

.map-node-ring {
  fill: var(--panel-2);
  stroke: var(--line);
  stroke-width: 2.5;
  transition:
    stroke 0.15s ease,
    filter 0.15s ease;
}

.map-node-visited .map-node-ring {
  fill: #2a2622;
  stroke: #4a423a;
}

.map-node-current .map-node-ring {
  stroke: var(--gold);
  stroke-width: 3;
}

.map-node-available .map-node-ring {
  stroke: var(--gold-dim);
  filter: drop-shadow(0 0 10px rgba(217, 164, 65, 0.5));
}

.map-node-available:hover .map-node-ring {
  stroke: var(--gold);
  filter: drop-shadow(0 0 16px rgba(217, 164, 65, 0.8));
}

.map-node-boss {
  stroke: var(--blood);
}

.map-node-elite {
  stroke: #a05c8c;
}

.map-node-camp {
  stroke: var(--ok);
}

.map-node-icon {
  font-size: 20px;
  fill: var(--text);
  pointer-events: none;
}

.map-node-visited .map-node-icon {
  opacity: 0.5;
}

.map-node-label {
  font-size: 12px;
  fill: var(--muted);
  pointer-events: none;
}

.map-hint {
  margin: 0;
}

/* События */
.event-icon {
  font-size: 2.2rem;
  margin-bottom: 4px;
}

.event-note {
  font-size: 0.9rem;
  margin: 0 0 8px;
}

.modal-actions-left {
  justify-content: flex-start;
  flex-wrap: wrap;
}

/* ---------- Сцена 4: битва (компактная раскладка) ---------- */

.battle-screen {
  justify-content: flex-start;
  padding: 8px 10px;
  gap: 8px;
  font-size: 13px;
}

.battle-topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(1280px, 98vw);
  padding: 6px 12px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.battle-topbar .map-topbar-title {
  font-size: 1rem;
  white-space: nowrap;
}

.battle-queue {
  flex: 1;
  display: flex;
  gap: 5px;
  overflow-x: auto;
  padding: 2px;
}

.queue-chip {
  flex: 0 0 auto;
  font-size: 0.7rem;
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.25);
  white-space: nowrap;
}

.queue-chip-current {
  border-color: var(--gold) !important;
  color: var(--gold);
  box-shadow: 0 0 8px rgba(217, 164, 65, 0.4);
}

.battle-main {
  display: flex;
  gap: 8px;
  width: min(1280px, 98vw);
  align-items: stretch;
}

.battle-field {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px;
  background:
    radial-gradient(600px 260px at 50% 50%, rgba(217, 164, 65, 0.06), transparent 70%),
    linear-gradient(180deg, var(--bg-2), var(--bg));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.battle-side-label {
  font-family: var(--font-title);
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 1px 0 3px;
}

.battle-divider {
  height: 1px;
  margin: 3px 0;
  background: linear-gradient(90deg, transparent, var(--gold-dim), transparent);
}

.battle-grid-row {
  display: flex;
  gap: 5px;
  margin-bottom: 5px;
}

.battle-grid-row .combat-slot {
  flex: 1;
  min-width: 0;
  min-height: 88px;
}

.combat-slot {
  flex: 1;
  min-width: 0;
  min-height: 128px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 4px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  transition:
    border-color 0.12s ease,
    box-shadow 0.12s ease;
}

.combat-slot-empty {
  justify-content: center;
  opacity: 0.5;
  cursor: default;
}

.combat-slot-dead {
  opacity: 0.28;
}

.combat-slot-targetable {
  border-color: var(--rust);
  box-shadow: 0 0 12px rgba(193, 97, 58, 0.5);
  animation: target-pulse 1.1s ease-in-out infinite;
}

@keyframes target-pulse {
  0%,
  100% {
    box-shadow: 0 0 8px rgba(193, 97, 58, 0.35);
  }
  50% {
    box-shadow: 0 0 18px rgba(193, 97, 58, 0.75);
  }
}

.combat-slot-active {
  border-color: var(--gold);
  box-shadow: 0 0 12px rgba(217, 164, 65, 0.45);
}

/* Аура полководца (класс warlord) */
.combat-slot-aura {
  outline: 1px solid rgba(217, 164, 65, 0.35);
  outline-offset: 2px;
}

/* Эффекты действий: атака — сдвиг, урон — вспышка */
.fx-lunge {
  animation: fx-lunge 0.5s ease;
}

@keyframes fx-lunge {
  40% {
    transform: translateY(-6px) scale(1.06);
  }
}

.fx-hit {
  animation: fx-hit 0.55s ease;
}

@keyframes fx-hit {
  30% {
    background: rgba(193, 97, 58, 0.45);
    filter: brightness(1.7);
    transform: translateX(3px);
  }
  60% {
    transform: translateX(-2px);
  }
}

/* Смерть отряда — плавное затухание */
.combat-slot-dead {
  animation: death-fade 0.9s ease forwards;
}

@keyframes death-fade {
  from {
    opacity: 0.6;
    filter: grayscale(0.3);
  }
  to {
    opacity: 0.28;
    filter: grayscale(1);
  }
}

/* ---------- Тултипы (ui/tooltip.js) ---------- */

.tooltip {
  position: fixed;
  z-index: 300;
  max-width: 300px;
  padding: 8px 12px;
  background: rgba(20, 15, 12, 0.97);
  border: 1px solid var(--gold-dim);
  border-radius: 8px;
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 0.82rem;
  line-height: 1.45;
  pointer-events: none;
}

/* ---------- Адаптив: минимум 1280×720, ниже — горизонтальный скролл ---------- */

@media (max-width: 1200px) {
  .battle-main {
    flex-direction: column;
  }

  .battle-log {
    width: 100%;
    max-height: 220px;
  }

  .battle-bottom {
    flex-wrap: wrap;
  }

  .battle-general {
    width: 100%;
  }
}

@media (max-width: 1024px) {
  /* Без ломки лэйаута — страница скроллится горизонтально */
  body {
    min-width: 1024px;
  }

  .creator-grid {
    grid-template-columns: 220px 1fr 300px;
  }
}

.combat-slot-units {
  display: flex;
  gap: 2px;
  align-items: flex-end;
  min-height: 30px;
}

.combat-slot-name {
  font-size: 0.74rem;
  text-align: center;
  line-height: 1.25;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Полоски HP / морали */
.bar {
  width: 100%;
  height: 6px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.4);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.25s ease;
}

.bar-hp .bar-fill {
  background: linear-gradient(90deg, #a33c3c, #d76a4a);
}

.bar-mor .bar-fill {
  background: linear-gradient(90deg, var(--gold-dim), var(--gold));
}

.bar-shield .bar-fill {
  background: linear-gradient(90deg, #3f6fa8, #6fb3e8);
}

/* Сетка поля: 2 ряда × 5 столбцов на сторону */
.battle-grid-row {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
}

.battle-grid-row .combat-slot {
  flex: 1;
  min-width: 0;
  min-height: 118px;
}

/* Клетка для перемещения */
.combat-slot-movable {
  border: 1px dashed var(--ok);
  background: rgba(127, 168, 107, 0.12);
  cursor: pointer;
  animation: movable-pulse 1.4s ease-in-out infinite;
}

@keyframes movable-pulse {
  0%,
  100% {
    background: rgba(127, 168, 107, 0.08);
  }
  50% {
    background: rgba(127, 168, 107, 0.22);
  }
}

/* Полководец под угрозой */
.battle-general-threat {
  border-color: var(--blood);
  box-shadow: 0 0 16px rgba(140, 47, 47, 0.5);
}

.battle-general-preview {
  display: flex;
  justify-content: center;
  margin-bottom: 8px;
}

.battle-general-stats {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 8px;
}

/* Точки AP */
.ap-dots {
  display: flex;
  gap: 4px;
  margin-top: 2px;
}

.ap-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid var(--line);
}

.ap-on {
  background: var(--gold);
  border-color: var(--gold-dim);
}

.panic-flag {
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  color: #e8b7b7;
  border: 1px solid var(--blood);
  border-radius: 4px;
  padding: 1px 6px;
  margin-top: 2px;
}

/* Лог боя */
.battle-log {
  width: 300px;
  display: flex;
  flex-direction: column;
  max-height: 560px;
}

.battle-log-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-right: 4px;
  font-size: 0.82rem;
}

.log-line {
  padding: 3px 8px;
  border-left: 2px solid var(--line);
  background: rgba(0, 0, 0, 0.18);
  border-radius: 0 6px 6px 0;
  line-height: 1.35;
}

.log-damage {
  border-left-color: var(--rust);
}

.log-heal {
  border-left-color: var(--ok);
}

.log-buff {
  border-left-color: var(--gold);
}

.log-death {
  border-left-color: var(--blood);
  color: #e8b7b7;
}

.log-turn {
  border-left-color: var(--gold-dim);
  font-family: var(--font-title);
  color: var(--gold);
}

.log-move {
  border-left-color: #5b8ab0;
}

.log-info {
  color: var(--muted);
}

/* Нижние панели */
.battle-bottom {
  display: flex;
  gap: 12px;
  width: min(1280px, 97vw);
  align-items: stretch;
}

.battle-general {
  width: 320px;
}

.battle-general-head {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}

.battle-general-head > div:last-child {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.battle-entity-name {
  font-family: var(--font-title);
  color: var(--text);
}

.battle-unit-panel {
  flex: 1;
}

.skill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0;
}

/* Оверлей конца боя */
.battle-over {
  position: fixed;
  inset: 0;
  background: rgba(10, 7, 5, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 90;
  backdrop-filter: blur(2px);
}

.battle-over-box {
  width: 420px;
  max-width: 92vw;
  text-align: center;
  border-color: var(--gold-dim);
  padding: 26px;
}

.battle-over-box .btn {
  margin-top: 12px;
}

/* ---------- Сцена 5: полевой лагерь ---------- */

.camp-screen {
  justify-content: flex-start;
  padding-top: 18px;
  gap: 12px;
}

.camp-tabs {
  display: flex;
  gap: 8px;
  width: min(1100px, 96vw);
}

.camp-content {
  width: min(1100px, 96vw);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.camp-army-panel {
  width: 100%;
}

.army-slots {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.army-slot {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px dashed var(--line);
  border-radius: 8px;
  transition: border-color 0.12s ease, background 0.12s ease;
}

.army-slot-over {
  border-color: var(--gold) !important;
  background: rgba(217, 164, 65, 0.1);
}

.army-slot-label {
  width: 90px;
  font-family: var(--font-title);
  color: var(--muted);
  flex: 0 0 auto;
}

.army-slot-empty {
  flex: 1;
  text-align: center;
  padding: 12px;
}

.army-slot .stack-card {
  flex: 1;
  min-width: 0;
}

.stack-actions {
  display: flex;
  gap: 6px;
  flex: 0 0 auto;
}

/* Магазин */
.shop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
}

.shop-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.shop-card-name {
  font-family: var(--font-title);
  color: var(--text);
}

.shop-card-desc {
  flex: 1;
  font-size: 0.86rem;
}

/* Инвентарь и экипировка */
.equip-target-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.equip-slots {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}

.equip-slot {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.equip-slot-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.equip-slot-item {
  font-family: var(--font-title);
  color: var(--gold);
  min-height: 1.4em;
}

.inv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}

.inv-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.inv-card-name {
  font-family: var(--font-title);
  color: var(--text);
}

.inv-card-desc {
  flex: 1;
  font-size: 0.82rem;
}

.stack-preview {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.22);
  border-radius: 8px;
}

.camp-flash {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  padding: 10px 18px;
  background: var(--blood);
  color: #f4e7d2;
  border-radius: 8px;
  box-shadow: var(--shadow);
  z-index: 120;
  animation: dialog-in 0.25s ease;
}

/* Визуальные слои юнитов (оружие/шлем) */
.unit-layer-bow {
  right: -12%;
  top: 6%;
  width: 46%;
  height: 68%;
  border: 3px solid #7a5a34;
  border-left: none;
  border-radius: 0 60% 60% 0;
}

.unit-layer-plume {
  left: 50%;
  top: -6%;
  width: 22%;
  height: 24%;
  transform: translateX(-50%) rotate(-12deg);
  background: linear-gradient(180deg, var(--gold), var(--rust));
  border-radius: 50% 50% 20% 20%;
}

/* ---------- Прокачка (перки) ---------- */

.perk-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.perk-row:last-child {
  border-bottom: none;
}

.perk-tree-name {
  width: 210px;
  flex: 0 0 auto;
  font-family: var(--font-title);
  color: var(--text);
}

/* ---------- Награды и мета-магазин ---------- */

.reward-panel {
  width: min(440px, 92vw);
}

.reward-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
}

.reward-line {
  font-size: 0.95rem;
}

.meta-shop-box {
  width: min(680px, 94vw);
  max-height: 86vh;
  overflow-y: auto;
}

.meta-shop-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.meta-offers {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px;
  margin: 12px 0;
}

.meta-offer {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.meta-offer-name {
  font-family: var(--font-title);
  color: var(--text);
}

.meta-offer-desc {
  flex: 1;
  font-size: 0.82rem;
  color: var(--muted);
}

/* ---------- Компактная раскладка боя (v2: всё помещается в экран) ---------- */

.battle-screen {
  padding: 8px 10px;
  gap: 8px;
  font-size: 13px;
}

.battle-topbar {
  padding: 6px 12px;
  gap: 10px;
}

.battle-topbar .map-topbar-title {
  font-size: 1rem;
}

.battle-topbar .btn {
  padding: 4px 12px;
  font-size: 0.8rem;
}

.queue-chip {
  font-size: 0.7rem;
  padding: 2px 8px;
}

.battle-main {
  gap: 8px;
  align-items: flex-start;
}

.battle-field {
  padding: 8px;
  gap: 2px;
}

.battle-side-label {
  font-size: 0.72rem;
  margin: 1px 0 3px;
}

.battle-divider {
  height: 1px;
  margin: 3px 0;
}

.battle-grid-row {
  gap: 5px;
  margin-bottom: 5px;
}

.battle-grid-row .combat-slot {
  min-height: 86px;
  gap: 2px;
  padding: 5px 3px;
}

.combat-slot-name {
  font-size: 0.66rem;
}

.combat-slot-units {
  min-height: 24px;
  gap: 1px;
}

.bar {
  height: 4px;
}

.ap-dots {
  margin-top: 1px;
  gap: 3px;
}

.ap-dot {
  width: 6px;
  height: 6px;
}

.panic-flag {
  font-size: 0.58rem;
  padding: 0 4px;
}

.battle-general {
  width: 208px;
  padding: 10px;
}

.battle-general-preview {
  transform: scale(0.8);
  transform-origin: center top;
  margin-bottom: 2px;
}

.battle-entity-name {
  font-size: 0.92rem;
}

.battle-unit-panel {
  padding: 10px;
}

.battle-hint {
  font-size: 0.72rem;
  margin-top: 2px;
}

.skill-row {
  gap: 5px;
  margin: 6px 0 2px;
}

.skill-row .btn {
  padding: 5px 10px;
  font-size: 0.78rem;
}

.battle-log {
  width: 224px;
  padding: 10px;
  max-height: 520px;
}

.battle-log-list {
  font-size: 0.72rem;
  gap: 3px;
}

.log-line {
  padding: 2px 6px;
}

.battle-screen .panel-title {
  font-size: 0.88rem;
  margin-bottom: 6px;
}

.battle-bottom {
  gap: 8px;
}

/* Юниты в слотах поля — меньше */
.unit-sm {
  width: 22px;
  height: 27px;
  transform: none;
}

.unit-sm .unit-mark {
  display: none;
}
