/* Chesslatro — продуктовая тема поверх Tailwind (design-tokens + анимации,
   которые нельзя выразить utility-классами). */

:root {
  --bg: #17181C;
  --surface: #22242B;
  --edge: #33363F;
  --text: #ECEEF3;
  --text-2: #9AA0AC;
  --danger: #E5484D;
  --success: #4CC38A;
  --gold: #F5B34C;
}

html, body { background: var(--bg); }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--edge); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

.tabular-nums { font-variant-numeric: tabular-nums; }

/* ---------- Board ---------- */

#board, #demo-board {
  grid-template-columns: repeat(var(--board-cols, 6), 1fr);
  grid-template-rows: repeat(var(--board-cols, 6), 1fr);
}

.sq {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1 / 1;
  cursor: default;
  transition: background-color 0.15s ease;
}
.sq.light { background: #2b2d35; }
.sq.dark { background: #22242B; }

.sq.is-selected { box-shadow: inset 0 0 0 3px var(--gold); background-color: #3a3320; }
.sq.is-legal { cursor: pointer; }
.sq.is-legal::after {
  content: "";
  position: absolute;
  width: 28%;
  height: 28%;
  border-radius: 999px;
  background: var(--success);
  opacity: 0.55;
}
.sq.is-legal.has-capture::after {
  width: 78%;
  height: 78%;
  border-radius: 10px;
  background: transparent;
  box-shadow: inset 0 0 0 3px var(--danger);
  opacity: 0.85;
}
.sq.is-legal:hover { background-color: #33362a; }
.sq.is-illegal-flash { animation: flash-illegal 0.4s ease; }
@keyframes flash-illegal {
  0%, 100% { background-color: inherit; }
  30% { background-color: rgba(229, 72, 77, 0.45); }
}

.piece {
  font-size: clamp(20px, 6.2vw, 40px);
  line-height: 1;
  user-select: none;
  cursor: pointer;
  transition: transform 0.15s ease;
  filter: drop-shadow(0 2px 2px rgba(0,0,0,0.45));
}
.piece:hover { transform: scale(1.08); }
.piece.player { color: var(--gold); }
.piece.enemy { color: var(--danger); }
.piece.is-selected-piece { transform: scale(1.12); filter: drop-shadow(0 0 6px rgba(245,179,76,0.75)); }
.piece.just-moved { animation: pop-in 0.25s ease; }
@keyframes pop-in {
  0% { transform: scale(0.55); opacity: 0.3; }
  100% { transform: scale(1); opacity: 1; }
}
.piece.captured-flash { animation: capture-burst 0.35s ease forwards; }
@keyframes capture-burst {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.6); opacity: 0; }
}

/* Score-fly popup shown above the board on a capture/combo */
.fly-pop {
  position: absolute;
  transform: translate(-50%, 0);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  white-space: nowrap;
  animation: fly-up 0.9s ease-out forwards;
  text-shadow: 0 2px 6px rgba(0,0,0,0.6);
}
@keyframes fly-up {
  0% { opacity: 0; transform: translate(-50%, 6px) scale(0.85); }
  15% { opacity: 1; transform: translate(-50%, -4px) scale(1.05); }
  100% { opacity: 0; transform: translate(-50%, -46px) scale(1); }
}

/* HUD shake on falling short at last move */
@keyframes hud-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(3px); }
}
#hud.shake { animation: hud-shake 0.4s ease; }

/* ---------- Joker cards ---------- */

.joker-card {
  position: relative;
  min-width: 156px;
  flex: 0 0 auto;
  background: linear-gradient(180deg, #262832 0%, #1e2027 100%);
  border: 1px solid var(--edge);
  border-radius: 14px;
  padding: 10px 12px;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}
@media (min-width: 1024px) {
  .joker-card { min-width: 0; width: 100%; }
}
.joker-card:hover, .joker-card.expanded {
  transform: translateY(-3px);
  border-color: rgba(245,179,76,0.55);
  box-shadow: 0 10px 24px rgba(0,0,0,0.4);
}
.joker-card .joker-desc {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.2s ease, opacity 0.2s ease, margin-top 0.2s ease;
}
.joker-card:hover .joker-desc,
.joker-card.expanded .joker-desc {
  max-height: 120px;
  opacity: 1;
  margin-top: 6px;
}

.shop-card {
  position: relative;
  background: linear-gradient(180deg, #262832 0%, #1e2027 100%);
  border: 1px solid var(--edge);
  border-radius: 16px;
  padding: 18px;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}
.shop-card:hover {
  transform: translateY(-4px);
  border-color: rgba(245,179,76,0.6);
  box-shadow: 0 14px 30px rgba(0,0,0,0.45);
}
.shop-card.is-picked { border-color: var(--success); box-shadow: 0 0 0 2px rgba(76,195,138,0.4); }
.shop-card.is-disabled { opacity: 0.55; }

/* ---------- Toasts ---------- */

.toast {
  pointer-events: auto;
  background: var(--surface);
  border: 1px solid var(--edge);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,0.45);
  animation: toast-in 0.25s ease;
}
.toast.toast-error { border-color: var(--danger); }
.toast.toast-success { border-color: var(--success); }
@keyframes toast-in {
  0% { opacity: 0; transform: translateY(-10px); }
  100% { opacity: 1; transform: translateY(0); }
}

/* ---------- Mode transitions ---------- */

.fade-in { animation: fade-in 0.28s ease; }
@keyframes fade-in {
  0% { opacity: 0; transform: scale(0.99); }
  100% { opacity: 1; transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}
