/* Tactical Frontier: поле, панель хода, выбор фракции, обучение, заставка.
   Общая раскладка экрана партии — в nardy.css (там игра стоит в списках
   квадратных досок и плашек игроков). Всё здесь начинается с tf- или
   привязано к body[data-game="tactics"], чтобы не задеть соседние игры. */

/* пиксельная графика: без сглаживания, иначе спрайты расплываются */
#board-tactics .tf-sprite,
#board-tactics .tf-ground,
#board-tactics .tf-solid,
.tf-mini { shape-rendering: crispEdges; image-rendering: pixelated; }
#board-tactics { background: #14171d; }

/* выделенный юнит пульсирует, цели — мягко дышат */
#board-tactics .tf-sel { animation: tf-pulse 1s ease-in-out infinite; }
#board-tactics .tf-target { animation: tf-breathe 1.4s ease-in-out infinite; }
#board-tactics .tf-pending { animation: tf-pulse .7s ease-in-out infinite; }
#board-tactics .tf-bubble { animation: tf-bubble 2.4s ease-in-out infinite; }
#board-tactics .tf-shimmer { animation: tf-breathe 1.2s ease-in-out infinite; }
#board-tactics .tf-glow { animation: tf-breathe 1.6s ease-in-out infinite; }
#board-tactics .tf-shield { animation: tf-breathe 1.8s ease-in-out infinite; }
@keyframes tf-pulse { 0%, 100% { opacity: 1 } 50% { opacity: .45 } }
@keyframes tf-breathe { 0%, 100% { opacity: .95 } 50% { opacity: .55 } }
@keyframes tf-bubble { 0%, 100% { opacity: .2 } 50% { opacity: 1 } }

/* --- правая колонка: состояние партии --- */

#tf-hud {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
}
#tf-hud.hidden { display: none; }
.tf-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--line);
}
#tf-ap { display: flex; gap: 4px; }
.tf-ap-dot {
  width: 12px;
  height: 12px;
  border: 2px solid #ffd54f;
  background: transparent;
  transform: rotate(45deg);
}
.tf-ap-dot.on { background: #ffd54f; }
#tf-ap.theirs .tf-ap-dot { border-color: var(--text-3); }
#tf-ap.theirs .tf-ap-dot.on { background: var(--text-3); }

#tf-unit {
  padding: 7px 10px;
  border-radius: var(--r-sm);
  background: var(--surface-1);
  border: 1px solid var(--line);
}
.tf-unit-head { display: flex; gap: 8px; align-items: center; }
.tf-unit-head .tf-mini { flex: none; background: #22262f; border-radius: 6px; padding: 2px; }
.tf-hpnum { color: #ff8a8a; font-weight: 600; }
.tf-acts { margin: 6px 0 0; padding-left: 16px; display: grid; gap: 3px; }
.tf-acts li { line-height: 1.3; }
.tf-cd { color: var(--warn); }

#tf-log {
  max-height: 96px;
  overflow-y: auto;
  padding: 6px 8px;
  border-radius: var(--r-sm);
  background: var(--surface-1);
  border: 1px solid var(--line);
  font-size: 12px;
  line-height: 1.35;
  color: var(--text-2);
}
.tf-log-line { display: flex; gap: 6px; align-items: baseline; }
.tf-log-line + .tf-log-line { margin-top: 2px; }
.tf-log-dot { width: 7px; height: 7px; flex: none; background: var(--text-3); }
.tf-log-line[data-side="w"] .tf-log-dot { background: #4fb3ff; }
.tf-log-line[data-side="b"] .tf-log-dot { background: #ff8a4c; transform: rotate(45deg); }
.tf-log-line:last-child { color: var(--text); }

.tf-tools { display: flex; gap: 6px; }
.tf-tools .btn { flex: 1; }

/* --- кнопки хода --- */

/* высота постоянная — два ряда кнопок: панель не прыгает при смене хода
   и выборе юнита, и кнопки под ней не уезжают из-под пальца */
#tf-actions { display: flex; flex-direction: column; gap: 6px; min-height: 86px; }
.tf-wait { display: grid; place-items: center; min-height: 86px; }
#tf-actions.hidden { display: none; }
.tf-modes { display: flex; flex-wrap: wrap; gap: 6px; }
.tf-modes .btn { flex: 1 1 40%; min-height: 40px; }
.tf-mode.off { opacity: .45; }

/* плашки: у белых квадратная точка, у чёрных ромб — сторона читается
   не только цветом */
body[data-game="tactics"] .prow[data-side="w"] .pdot { border-radius: 2px; background: #4fb3ff; }
body[data-game="tactics"] .prow[data-side="b"] .pdot { border-radius: 0; transform: rotate(45deg); background: #ff8a4c; }
body[data-game="tactics"] .prow .pdot { opacity: .45; }
body[data-game="tactics"] .prow.online .pdot { opacity: 1; }
body[data-game="tactics"] .prow .peaten { font-variant-numeric: tabular-nums; letter-spacing: .02em; }

/* --- поверх поля: выбор фракции, обучение, заставка --- */

.tf-overlay {
  position: absolute;
  inset: 0;
  z-index: 8;
  overflow-y: auto;
  padding: 8px;
  border-radius: 10px;
  background: rgba(12, 14, 19, .9);
  backdrop-filter: blur(2px);
}
.tf-overlay.hidden { display: none; }
.tf-draft-head h3 { margin: 0 0 2px; font-size: 16px; }
.tf-mode-tag {
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  margin-left: 4px;
  border-radius: var(--r-full);
  background: var(--surface-3);
  color: var(--text-2);
  vertical-align: middle;
}
.tf-draft-head p { margin: 0 0 8px; font-size: 12px; }
.tf-factions { display: grid; gap: 6px; }
@media (min-aspect-ratio: 1/1) and (min-width: 700px) {
  .tf-factions { grid-template-columns: repeat(3, 1fr); }
}
.tf-faction {
  display: flex;
  flex-direction: column;
  gap: 3px;
  text-align: left;
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface-1);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.tf-faction:active { transform: scale(.99); }
.tf-faction.picked { border-color: var(--ok); cursor: default; }
.tf-fhead { display: flex; align-items: center; gap: 8px; }
.tf-fname { font-weight: 700; font-size: 15px; flex: 1; }
.tf-fsprites { display: flex; gap: 2px; }
.tf-fsprites .tf-mini { background: #22262f; border-radius: 5px; padding: 1px; }
.tf-pick {
  padding: 5px 10px;
  border-radius: var(--r-full);
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 13px;
  font-weight: 600;
}
.tf-fline { color: var(--text-2); }
.tf-fline b { color: #ff8a8a; font-weight: 600; }
.tf-funits { display: grid; gap: 6px; margin-top: 4px; }
.tf-funit { display: flex; gap: 8px; align-items: center; font-size: 13px; line-height: 1.3; }
.tf-funit .tf-mini { flex: none; background: #22262f; border-radius: 6px; padding: 2px; }
.tf-waiting { text-align: center; margin-top: 12px; }

.tf-tutor { display: grid; place-items: center; background: rgba(12, 14, 19, .72); }
.tf-tutor.hidden { display: none; }
.tf-tutor-box {
  max-width: 320px;
  padding: 14px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  box-shadow: var(--sh-2);
}
.tf-tutor-box p { margin: 8px 0 12px; line-height: 1.4; }

.tf-splash {
  position: absolute;
  inset: 0;
  z-index: 9;
  pointer-events: none;
  display: grid;
  place-content: center;
  text-align: center;
  gap: 6px;
  border-radius: 10px;
  animation: tf-fade .35s ease both;
}
.tf-splash.hidden { display: none; }
.tf-splash.win { background: radial-gradient(60% 45% at 50% 50%, rgba(79, 179, 255, .22), rgba(10, 12, 18, .7)); }
.tf-splash.loss { background: radial-gradient(60% 45% at 50% 50%, rgba(255, 92, 92, .2), rgba(10, 12, 18, .82)); }
.tf-splash.draw { background: rgba(10, 12, 18, .72); }
#tf-splash-title {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-weight: 800;
  font-size: clamp(30px, 11vmin, 64px);
  letter-spacing: .08em;
  text-shadow: 3px 3px 0 #0b0d12;
  animation: tf-drop .55s steps(6, end) both;
}
.tf-splash.win #tf-splash-title { color: #ffd54f; }
.tf-splash.loss #tf-splash-title { color: #ff6b6b; }
.tf-splash.draw #tf-splash-title { color: #d9dde5; }
#tf-splash-sub { color: var(--text-2); animation: tf-fade .5s ease .4s both; }
@keyframes tf-fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes tf-drop { from { transform: translateY(-40px) scale(1.3); opacity: 0 } to { transform: none; opacity: 1 } }

@media (prefers-reduced-motion: reduce) {
  #board-tactics *, .tf-splash, .tf-splash * { animation: none !important; }
}

/* портрет: панель ниже поля — журнал короче, кнопки крупнее */
@media (orientation: portrait) {
  #tf-log { max-height: 64px; }
  body[data-game="tactics"] #hint { flex-basis: 100%; }
  body[data-game="tactics"] #actionbar #tf-actions { flex-basis: 100%; }
}
