/* cardtactics: rules used only by the cardtactics pages (loaded after base.css). */
/* Card Tactics board: a 7 x 6 float-grid (same technique as chess/checkers -
   note the explicit width override below, since the shared .square
   base class hardcodes 12.5% for an 8-column board). Sides are told
   apart by shape, not by color: Black is a filled disc, White an
   outlined disc. The two back rows (the goal rows) carry a dashed frame. */
#cardtactics-board {
  display: block;
  width: 100%;
  max-width: 420px;
  border: 3px solid var(--border);
  background: var(--square-light);
  box-sizing: border-box;
  overflow: hidden;
  margin: 0 auto;
}

.cardtactics-square {
  width: calc(100% / 6);
  background: var(--square-light);
  border: 1px solid var(--border);
}

.cardtactics-square-movable {
  background: linear-gradient(135deg, var(--text) 0, var(--text) 12px, transparent 12px) var(--square-dark);
}

.cardtactics-square-goal::before {
  content: "";
  position: absolute;
  top: 6%;
  left: 6%;
  width: 88%;
  height: 88%;
  border: 2px dashed var(--border);
  box-sizing: border-box;
  pointer-events: none;
}

.cardtactics-piece {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 72%;
  height: 72%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  box-sizing: border-box;
  pointer-events: none;
}

.cardtactics-piece-black {
  background: #111;
  border: 2px solid #000;
}

.cardtactics-piece-white {
  background: #fff;
  border: 3px solid var(--border);
}

/* Small icons for the color-choice picker and board placeholder,
   matching the board's own piece styling. */
.cardtactics-icon-piece {
  display: inline-flex;
  width: 1.2em;
  height: 1.2em;
  border-radius: 50%;
  box-sizing: border-box;
  vertical-align: middle;
}

.cardtactics-icon-piece-black {
  background: #111;
  border: 2px solid #000;
}

.cardtactics-icon-piece-white {
  background: #fff;
  border: 2px solid var(--border);
}

.cardtactics-home-line {
  text-align: center;
  font-weight: 700;
  margin: 0 auto 0.3rem;
  max-width: 420px;
}

.cardtactics-goal-label {
  text-align: center;
  font-size: 0.85rem;
  margin: 0.15rem auto;
  max-width: 420px;
}

.cardtactics-cards-head {
  text-align: center;
  font-weight: 700;
  margin: 0.6rem auto 0.3rem;
  max-width: 420px;
}

/* The three open cards (buttons) and the line with the face-down pile.
   Each card holds a name and its moves as arrows, seen from the side to
   move. */
.cardtactics-cards-row {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  margin: 0 auto 0.4rem;
  max-width: 420px;
}

/* Flexbox `gap` fallback: margin-based spacing instead, since some E-Ink browsers (Tolino confirmed) don't support `gap` on a flex container and render items with zero space between them. */
.cardtactics-cards-row > * {
  margin: 0 0.5rem 0.5rem 0;
}

.cardtactics-cards-row > *:last-child {
  margin-right: 0;
}

.cardtactics-next-row {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  margin: 0.2rem auto 0;
  max-width: 420px;
  font-size: 0.85rem;
}

/* Flexbox `gap` fallback (see above). */
.cardtactics-next-row > * {
  margin: 0 0.5rem 0.3rem 0;
}

.cardtactics-next-row > *:last-child {
  margin-right: 0;
}

.cardtactics-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 88px;
  min-height: 44px;
  padding: 0.3rem;
  border: var(--border-width) solid var(--border);
  border-radius: 4px;
  background: #fff;
  color: var(--text);
  box-sizing: border-box;
  cursor: pointer;
}

/* Flexbox `gap` fallback (see above). */
.cardtactics-card > * {
  margin: 0 0 0.2rem 0;
}

.cardtactics-card > *:last-child {
  margin-bottom: 0;
}

.cardtactics-card-selected {
  outline: 3px solid var(--border);
  outline-offset: -2px;
  background: var(--square-dark);
}

.cardtactics-card-name {
  font-weight: 700;
  font-size: 0.8rem;
}

/* The moves: one line of arrows per move. */
.cardtactics-card-moves {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.cardtactics-card-move {
  font-size: 1.1rem;
  line-height: 1.25;
  letter-spacing: 0.05em;
}
