/* Spawn tiles retain team colors; square portraits use compact team badges. */
:root { --green: #13805a; --red: #c33e4b; }
.show-spawns .cell.spawn::before {
  inset: 1px; border: 2px solid var(--spawn-color); border-radius: 0;
  background: var(--spawn-fill); box-shadow: inset 0 0 0 1px #18382c26;
}
.show-spawns .cell.spawn.has-unit::before { display: block; }
.cell.spawn.first { --spawn-color: #53d6a4; --spawn-fill: #1baf7d38; }
.cell.spawn.second { --spawn-color: #fb7280; --spawn-fill: #e9465838; }
.spawn-order {
  display: none; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  place-items: center; color: #fff9e9; opacity: .34;
  text-shadow: 0 1px 2px #223a24b3; font-size: clamp(12px, 1.6vw, 22px);
  font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1;
  pointer-events: none; user-select: none; z-index: 6;
}
.show-spawn-order .spawn-order { display: grid; }
.cell.has-unit .spawn-order { opacity: .6; text-shadow: 0 1px 2px #14251ff2, 0 0 4px #14251f99; }
.unit, .drag-ghost {
  border: 0; border-radius: 5px; overflow: visible;
  box-shadow: none; background: transparent;
}
.unit { width: 86%; height: auto; aspect-ratio: 1; max-height: 90%; container: hero-token / inline-size; }
.unit.first, .drag-ghost.first { --unit-color: #258765; }
.unit.second, .drag-ghost.second { --unit-color: #b84e5c; }
.unit.selected { box-shadow: none; }
.unit-face {
  position: absolute; inset: 0; display: block; border: 1px solid #314436;
  border-radius: inherit; overflow: hidden; box-shadow: 0 2px 4px #1627197a;
  background: transparent; pointer-events: none;
}
.unit-image { position: absolute; inset: 0; display: block; }
/* Fade the image and its fallback as one layer, leaving the frame and team badge clear. */
:is(.unit, .drag-ghost, .selection-avatar).phantom .unit-image { opacity: .45; }
.unit-face .portrait, .selection-avatar .portrait { transform: scale(1.2); }
.portrait.summon-portrait { object-fit: contain; }
.unit-face .portrait.summon-portrait, .selection-avatar .portrait.summon-portrait { transform: none; }
.unit-badge {
  position: absolute; right: -2px; bottom: -2px; width: 17px; height: 17px;
  display: grid; place-items: center; border-radius: 4px; border: 1px solid #fff5;
  color: #fff; background: var(--unit-color); box-shadow: 0 1px 2px #132c2473;
  font-size: 11px; font-weight: 600; line-height: 1; z-index: 6; pointer-events: inherit;
}
.unit-entry {
  position: absolute; left: -2px; top: -2px; min-width: 17px; height: 17px; padding: 0 3px;
  display: grid; place-items: center; border-radius: 3px; border: 1px solid #eee9d969;
  color: #faf8ed; background: #344237e8; box-shadow: 0 1px 2px #18241c38;
  font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1;
  z-index: 6; pointer-events: inherit;
}
.unit.second .unit-entry, .drag-ghost.second .unit-entry {
  color: #2d3c31; background: #fffbed; border-color: #d3d8c9;
}
.drag-ghost.acted .portrait-fallback { filter: grayscale(1) brightness(.48); }
.selection-avatar, .selection-avatar.second { border: 1px solid #314436; border-radius: 5px; }
.selection-avatar.acted :is(.portrait, .portrait-fallback) { filter: grayscale(1) brightness(.48); }
.selection-bar, .selection-actions { flex-wrap: wrap; }
.selection-heading { display: flex; align-items: center; flex-wrap: wrap; gap: 14px; }
.entry-number-control { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: #68745f; white-space: nowrap; }
.entry-number-select { min-width: 76px; min-height: 34px; border: 1px solid #d8dfd1; border-radius: 5px; background: #f7f8f2; color: #334a39; padding: 5px 7px; font: inherit; }
.hero-card .portrait-wrap { border-width: 1px; border-color: #d9ddcf; }
.side-tab { border: 1px solid transparent; font-size: .875rem; font-weight: 600; }
.side-tab.first { color: var(--green); }
.side-tab.second { color: var(--red); }
.side-tab.first.active { background: var(--green); color: #fff; border-color: var(--green); }
.side-tab.second.active { background: var(--red); color: #fff; border-color: var(--red); }
.team-counts i { width: 7px; height: 7px; border-radius: 2px; }
.spawn-legend i { width: 9px; height: 9px; border-radius: 0; background: color-mix(in srgb,currentColor 18%,transparent); }
.round-panel { display: flex; justify-content: center; align-items: center; gap: 18px; padding: 5px 14px; border-top: 1px solid #edf0e5; background: #f8f9f3; }
.round-heading { display: flex; justify-content: center; align-items: baseline; gap: 6px; min-width: 112px; font-size: .875rem; color: #64715f; white-space: nowrap; }
.round-heading strong { font-size: 1.125rem; color: #4e405e; font-weight: 650; font-variant-numeric: tabular-nums; min-width: 22px; text-align: center; }
.round-total { color: #86917c; font-size: .875rem; }
.round-arrow { width: 44px; height: 40px; color: #6c6151; }
.round-arrow svg { width: 20px; height: 20px; }
.poison-toggle.active { color: #7c5c95; background: #f0eaf5; }
.fog-definitions { position: absolute; overflow: hidden; pointer-events: none; }
.poison-mist { position: absolute; inset: 0; pointer-events: none; z-index: 2; background: #622a8720; overflow: hidden; }
.poison-puff { width: 105%; height: 105%; position: absolute; left: -2.5%; top: -2.5%; opacity: .86; transform: rotate(var(--fog-rotation)); animation: mist-breathe var(--fog-duration) ease-in-out infinite alternate; animation-delay: var(--fog-delay); }
.cell.poisoned::after { border-color: #e9d1ff99; }
.cell[aria-selected='true']::after { border: 1px solid #fff2bc; background: #ffefb833; opacity: 1; }
.safe-zone { position: absolute; border: 1px dashed #d9c4e6c9; box-shadow: 0 0 5px #d8bae52b; pointer-events: none; z-index: 3; }
.cell.poisoned .unit { z-index: 5; }
@keyframes mist-breathe { from { opacity: .66; } to { opacity: .94; } }
@media (max-width:540px) {
  .board-tools { height: auto; flex-wrap: wrap; }
  .history-tools { margin-left: auto; }
  .spawn-order { font-size: 12px; }
  .unit .unit-entry { min-width: 14px; height: 14px; font-size: 10px; padding: 0 2px; }
  .selection-bar.has-selection { flex-direction: column; align-items: stretch; gap: 8px; }
  .selection-heading { justify-content: space-between; gap: 8px; }
  .round-panel { gap: 12px; padding: 3px 10px; }
  .round-arrow { height: 44px; }
  .board-tools .tool-button { gap: 3px; padding: 0 5px; }
  .board-tools .tool-button svg { width: 15px; height: 15px; }
  .history-tools .icon-button { width: 27px; }
  .history-tools .tool-divider { display: none; }
  .unit { border: 0; border-radius: 4px; }
  .unit .unit-badge { width: 14px; height: 14px; border-radius: 3px; font-size: 10px; }
  .show-spawns .cell.spawn::before { border-width: 1.5px; }
}
@container hero-token (max-width:22px) {
  .unit .unit-entry { min-width: 9px; height: 9px; padding: 0 1px; font-size: 7px; border-radius: 2px; }
  .unit .unit-badge { width: 9px; height: 9px; font-size: 7px; border-radius: 2px; }
}
@media (prefers-reduced-motion:reduce) { .poison-puff { animation: none; opacity: .8; } }
