/* Army builder chrome. The board (board.css) and the game-screen shell
 * (app-shell.css) are shared with play.html and puzzle.html; only the pieces
 * palette and the budget meter are specific to this screen. */

/* The half being built stays lit; the opponent's half steps back so the eye
 * knows where it may put something down. */
.square.is-inactive { filter: brightness(0.72) saturate(0.75); cursor: default; }

/* Above the board, and no wider than it. */
.builder-tabs {
  grid-template-columns: 1fr 1fr;
  width: min(100%, 820px);
  margin: 0 auto 14px;
}

.player-tab {
  display: grid;
  gap: 3px;
  border: 0;
  background: none;
  font: inherit;
  cursor: pointer;
}

.tab-state {
  color: var(--app-muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.player-tab.is-active .tab-state { color: var(--app-gold); }
.player-tab.is-done .tab-state { color: var(--app-green); }

.budget-card {
  display: grid;
  gap: 10px;
  padding: 16px 18px;
  border: 1px solid var(--app-line);
  border-radius: 18px;
  background: var(--app-panel);
  box-shadow: inset 0 1px 0 #fff;
}

.budget-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

#meter-label {
  color: var(--app-text);
  font-size: 1.15rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

#count-label { color: var(--app-muted); font-size: 0.85rem; }

.budget-meter {
  height: 10px;
  border-radius: 999px;
  background: rgba(43, 111, 147, 0.12);
  overflow: hidden;
}

.budget-meter span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--app-blue);
  transition: width 0.16s ease-out;
}

.budget-meter span.is-exact { background: var(--app-green); }
.budget-meter span.is-over { background: var(--app-red); }

.palette {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.palette-piece {
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 10px 4px 8px;
  border: 1px solid var(--app-line);
  border-radius: 16px;
  background: var(--app-panel);
  box-shadow: var(--shadow);
  font: inherit;
  cursor: pointer;
}

.palette-piece img { width: 44px; height: 44px; }

.palette-name {
  color: var(--app-muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.palette-cost {
  color: var(--app-text);
  font-size: 0.95rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.palette-piece:hover { border-color: rgba(43, 111, 147, 0.4); background: #fff; }

.palette-piece.is-active {
  border-color: rgba(180, 140, 60, 0.55);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px rgba(180, 140, 60, 0.45);
}

/* Still selectable — it only says the budget will not stretch that far. */
.palette-piece.is-unaffordable { opacity: 0.42; }

.issue-list {
  display: grid;
  gap: 7px;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--app-muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.issue-list li { padding-inline-start: 18px; position: relative; }

.issue-list li::before {
  content: "•";
  position: absolute;
  inset-inline-start: 4px;
  color: var(--app-red);
}

.issue-list li.is-current { color: var(--app-text); }

.issue-list li.is-ready { color: var(--app-green); font-weight: 700; }
.issue-list li.is-ready::before { content: "✓"; color: var(--app-green); }

.builder-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.start-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 64px;
  border: 1px solid rgba(43, 125, 95, 0.4);
  border-radius: 18px;
  color: var(--app-green);
  background: rgba(43, 125, 95, 0.12);
  box-shadow: var(--shadow);
  font: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
}

.start-button:not(:disabled):hover { background: rgba(43, 125, 95, 0.2); }
.start-button:disabled { color: var(--app-muted); border-color: var(--app-line); background: var(--app-panel-soft); cursor: not-allowed; }

.builder-top-action {
  min-width: 0;
  min-height: 48px;
  padding: 0 16px;
  font-size: 0.88rem;
}

/* Once the sidebar drops under the board, the pieces have to be the first
 * thing under it — on a phone anything below them is off-screen while you are
 * placing an army, and the palette is the half of the screen you keep tapping. */
@media (max-width: 1050px) {
  .builder-tabs { max-width: 720px; }
  .game-sidebar > .palette { order: -1; }
}

/* The phone budget for this screen: the switch, the board and both rows of
 * pieces have to sit on one 844px-tall screen, because those are the three
 * things you use on every single placement. Everything else may scroll. */
@media (max-width: 720px) {
  /* The only action up here is "Learn", and the nav bar already carries that
   * link one row above — 52px for a second copy of it is not a trade worth
   * making when the pieces are what needs the room. */
  .app-top-actions { display: flex; gap: 5px; }
  .builder-top-action {
    min-height: 36px;
    padding: 0 7px;
    border-radius: 12px;
    font-size: 0.62rem;
  }
  .builder-top-action + .builder-top-action { display: inline-flex; }

  .builder-tabs { margin-bottom: 8px; }
  .player-tab { padding: 8px 10px; font-size: 0.86rem; }
  .board-caption { margin-top: 8px; }
  .palette { grid-template-columns: repeat(4, 1fr); gap: 6px; }
  .palette-piece { padding: 5px 2px 4px; border-radius: 12px; }
  .palette-piece img { width: 30px; height: 30px; }
  .palette-name { font-size: 0.55rem; }
  .palette-cost { font-size: 0.85rem; }
  .game-sidebar { gap: 12px; }
  .start-button {
    position: sticky;
    bottom: 10px;
    z-index: 2;
    min-height: 52px;
    box-shadow: 0 10px 24px rgba(44, 36, 30, 0.18);
  }
}
