:root {
  --bg: #0f0c08;
  --panel: #1a1208;
  --border: #3d3020;
  --gold: #c9a84c;
  --text: #d4c49a;
  --river: #2c4a5e;
  --bridge: #8a6e30;
  --ford: #5a7d5e;
  --castle: #6e3030;
}

* { box-sizing: border-box; }

/* Hint при наведенні курсором на фігуру: загрози (прямі й пасивні) +
   релевантні терен-бонуси. Слідує за курсором, не заважає кліку
   (pointer-events: none), ховається за межами дошки/на порожньому гексі. */
.hover-tooltip {
  display: none;
  position: fixed;
  z-index: 50;
  pointer-events: none;
  max-width: 260px;
  padding: 8px 10px;
  background: var(--panel);
  border: 1px solid var(--gold);
  border-radius: 4px;
  color: var(--text);
  font-family: 'Crimson Text', Georgia, serif;
  font-size: 13px;
  line-height: 1.4;
  white-space: pre-line;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
}
.hover-tooltip :first-line,
.hover-tooltip-title { color: var(--gold); font-weight: 600; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(rgba(15,12,8,0.8), rgba(15,12,8,0.87)),
    url('../img/Stone_Texture.jpg') center center / cover no-repeat fixed;
  color: var(--text);
  font-family: 'Crimson Text', Georgia, serif;
}

/* Декор бічних зон — смолоскип + штандарт разом, вертикальною групою,
   центрованою по висоті незайнятого простору обабіч центрованого контенту
   (.top-bar/.layout, max-width: 1632px). Фіксовані відносно вікна, не
   залежать від прокрутки. Приховуються, якщо вільного місця замало (див.
   media query нижче). */
.deco-side {
  position: fixed;
  top: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  pointer-events: none;
  z-index: 1;
}
.deco-side.deco-left { left: calc(50% - 816px - 10px); transform: translate(-100%, -50%); }
.deco-side.deco-right { left: calc(50% + 816px + 10px); transform: translateY(-50%); }

.deco-torch, .deco-crest {
  object-fit: contain;
  filter: drop-shadow(0 6px 16px rgba(0,0,0,.6));
}
/* Розмір підібраний так, щоб влазити в бічний простір навіть на звичайному
   1920px екрані (гутер ~144px мінус запас на смугу прокрутки): 110px
   штандарт + 10px відступ від контенту = 120px, з невеликим запасом. */
.deco-torch { width: 55px; opacity: .95; }
.deco-crest { width: 110px; max-height: 50vh; opacity: .92; }
.deco-torch.deco-mirror { transform: scaleX(-1); }

@media (max-width: 1870px) {
  .deco-side { display: none; }
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 12px 24px;
  max-width: 1632px;
  margin: 0 auto;
  border-bottom: 1px solid var(--border);
}

.brand {
  font-size: 20px;
  letter-spacing: 2px;
  color: var(--gold);
  text-decoration: none;
  flex: 0 0 auto;
}
.brand:hover { color: #e8c874; }

.turn-indicator {
  font-size: 16px;
  letter-spacing: .5px;
  color: var(--gold);
  text-align: center;
  flex: 1 1 auto;
}

.mode-indicator {
  font-size: 13px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 6px 14px;
  flex: 0 0 auto;
  white-space: nowrap;
}

.hints-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 6px 14px;
  flex: 0 0 auto;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: color .2s ease, border-color .2s ease;
}
.hints-toggle:hover { color: var(--gold); border-color: var(--gold); }
.hints-toggle input {
  width: 14px;
  height: 14px;
  accent-color: var(--gold);
  cursor: pointer;
}

/* Модальне вікно кінця партії — штандарт сторони-переможця, причина
   завершення, кнопка ОК. Ховається/показується через display у main.js. */
.win-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.win-modal-card {
  max-width: 360px;
  width: 90%;
  border: 2px solid var(--gold);
  background: rgba(15,12,8,0.92);
  padding: 32px 36px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.6);
  text-align: center;
}
.win-modal-crest {
  height: 180px;
  width: auto;
  max-width: 100%;
  margin: 0 auto 20px;
  display: block;
}
.win-modal-title {
  font-family: 'Cinzel Decorative', 'Cinzel', serif;
  color: var(--gold);
  font-size: 26px;
  letter-spacing: 2px;
  margin-bottom: 10px;
  text-shadow: 0 2px 6px rgba(0,0,0,0.9);
}
.win-modal-reason {
  font-family: 'Crimson Text', Georgia, serif;
  color: var(--text);
  font-size: 16px;
  margin-bottom: 24px;
}
.win-modal-ok {
  font-family: 'Cinzel', serif;
  font-size: 14px;
  letter-spacing: 2px;
  text-transform: uppercase;
  background: var(--gold);
  color: #1a1208;
  border: none;
  padding: 10px 32px;
  cursor: pointer;
  transition: background .2s ease;
}
.win-modal-ok:hover { background: #e8c874; }

.log-gameover {
  color: var(--gold);
  font-weight: 600;
}

.layout {
  display: flex;
  gap: 24px;
  padding: 24px;
  max-width: 1632px;
  margin: 0 auto;
}

#board {
  background: var(--panel);
  border: 1px solid var(--border);
}

.side-panel {
  flex: 0 0 520px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel-row {
  display: flex;
  gap: 16px;
  align-items: stretch;
}
.panel-row .panel-block {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.panel-block {
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 12px 16px;
}

.panel-block h3 {
  margin: 0 0 8px;
  font-size: 13px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--gold);
}

#move-log { margin: 0; padding-left: 20px; font-size: 14px; height: 450px; overflow-y: auto; flex: 0 0 450px; }

.log-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 8px;
}
.log-header h3 { margin: 0; }

.save-btn {
  font-family: 'Crimson Text', Georgia, serif;
  font-size: 12px;
  letter-spacing: .5px;
  padding: 5px 10px;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  cursor: pointer;
  white-space: nowrap;
  transition: color .15s ease, border-color .15s ease;
}
.save-btn:hover { color: var(--gold); border-color: var(--gold); }

.castle-btn {
  width: 100%;
  padding: 10px;
  font-family: 'Crimson Text', Georgia, serif;
  font-size: 15px;
  letter-spacing: 1px;
  background: var(--gold);
  color: #1a1208;
  border: 1px solid var(--gold);
  cursor: pointer;
  transition: all .15s ease;
}
.castle-btn:hover:not(:disabled) { background: #e8c874; }
.castle-btn:disabled {
  background: transparent;
  color: var(--border);
  border-color: var(--border);
  cursor: default;
}
.castle-btn.active { background: #8b1a1a; color: var(--text); border-color: #a82020; }

.castle-hint { font-size: 12px; color: var(--text); margin-top: 6px; opacity: .8; }

/* Втрачені фігури — рядок іконок на сторону замість тексту */
.captured-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
}
.captured-row + .captured-row { margin-top: 8px; }
.captured-side-label {
  flex: 0 0 48px;
  font-size: 13px;
  color: var(--text);
  opacity: .75;
}
.captured-icons {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  flex: 1 1 auto;
}
.captured-icon {
  width: 32px;
  height: 32px;
  object-fit: contain;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 4px;
}
.captured-empty { font-size: 13px; color: var(--text); opacity: .5; }

/* Панель "Фігура" — картинка обраної фігури + пояснення її логіки */
.figure-icon {
  display: flex;
  justify-content: center;
  min-height: 105px;
  align-items: center;
}
.figure-icon img {
  width: 105px;
  height: 105px;
  object-fit: contain;
}
.debug-explain {
  font-size: 12px;
  white-space: pre-wrap;
  line-height: 1.5;
  height: 450px;
  overflow-y: auto;
  opacity: .9;
  flex: 0 0 450px;
}
