:root {
  --cell: 56px;
  --bg: #1e1b16;
  --ink: #f3ead7;
  --ground: #5a7a44;
  --tree: #213d24;
  --temple: #b8962e;
  --move: #7fd1ff;
  --attack: #ff5d5d;
  --select: #ffe066;
  --team-1: #2f6fb3;
  --team-2: #b3412f;
}

body {
  margin: 24px;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

h1 { margin: 0; letter-spacing: 0.1em; }

.status { min-height: 1.4em; text-align: center; max-width: 640px; }

/* The board is a positioned box: the cell grid sits in normal flow and
   the token layer is laid over it. */
.board {
  position: relative;
  padding: 6px;
  background: #0d0b08;
  border-radius: 6px;
}

.cells {
  display: grid;
  gap: 2px;
}

.tokens {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.token {
  position: absolute;
  width: var(--cell);
  height: var(--cell);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: left 150ms linear, top 150ms linear, opacity 150ms ease;
}

.cell {
  width: var(--cell);
  height: var(--cell);
  background: var(--ground);
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  text-align: center;
  position: relative;
  cursor: pointer;
  box-sizing: border-box;
  border: 2px solid transparent;
}

.cell.tree { background: var(--tree); cursor: default; }
.cell.temple { background: #6e5a1f; }
.cell.temple.locked { opacity: 0.6; }
.cell.temple.open { box-shadow: inset 0 0 0 2px var(--temple); }
.cell.base-1 { background: #34507a; }
.cell.base-2 { background: #7a3a30; }
.cell.portal-A { background: #5b3f86; }
.cell.portal-B { background: #2c6b6b; }

.cell.move { border-color: var(--move); }
.cell.attack { border-color: var(--attack); }
.cell.selected { border-color: var(--select); }

.unit {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  --pulse: transparent;
}
.unit.team-1 { background: var(--team-1); }
.unit.team-2 { background: var(--team-2); }
.unit.spent { opacity: 0.45; }
.unit .letter { font-size: 16px; line-height: 1; }
.unit .hp { font-size: 9px; line-height: 1; }

/* Units of the active team that can still act pulse with a white ring. */
.unit.ready {
  --pulse: #ffffff;
  animation: ready-pulse 1.2s ease-in-out infinite;
}
/* A unit that must step off a portal exit pulses gold instead. */
.unit.must-step {
  --pulse: var(--select);
}

@keyframes ready-pulse {
  0%, 100% { box-shadow: 0 0 0 2px var(--pulse), 0 1px 3px rgba(0, 0, 0, 0.5); }
  50% { box-shadow: 0 0 0 7px transparent, 0 1px 3px rgba(0, 0, 0, 0.5); }
}

button {
  padding: 8px 18px;
  font-size: 14px;
  border-radius: 4px;
  border: 1px solid #555;
  background: #2b2620;
  color: var(--ink);
  cursor: pointer;
}
button:hover { background: #3a332b; }

@media (prefers-reduced-motion: reduce) {
  .token { transition: none; }
  .unit.ready { animation: none; }
}
