/* All visual components: buttons, cards, modals, counters, picker, alloc, dice, etc. */

/* ============ Buttons ============ */
.btn {
  border: 1px solid var(--line-bright);
  background: var(--bg-2);
  color: var(--text);
  padding: 10px 18px;
  font-family: var(--font-body); font-weight: 500;
  font-size: var(--fs-sm); letter-spacing: 0.12em; text-transform: uppercase;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex; align-items: center; gap: 8px;
}
.btn:hover { background: var(--bg-3); border-color: var(--yellow); }
.btn:disabled { opacity: 0.35; cursor: not-allowed; }
.btn:disabled:hover { background: var(--bg-2); border-color: var(--line-bright); }
.btn.primary {
  background: var(--yellow); color: var(--bg-0); border-color: var(--yellow);
  box-shadow: 0 0 12px rgba(240,197,66,0.3);
}
.btn.primary:hover { background: #ffd64f; }
.btn.danger { color: var(--red); border-color: var(--red-deep); }
.btn.danger:hover { background: var(--red-deep); color: white; }
.btn.ghost { background: transparent; border: 1px dashed var(--line-bright); }
.btn.blue { color: var(--blue); border-color: var(--blue-deep); }
.btn.red { color: var(--red); border-color: var(--red-deep); }

/* ============ Unit Cards ============ */
.units-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}
.unit-card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  position: relative;
  transition: all 0.15s;
}
.unit-card.side-blue { border-left: 3px solid var(--blue); }
.unit-card.side-red { border-left: 3px solid var(--red); }
.unit-card.dead { opacity: 0.4; }
.unit-card.dead::after {
  content: 'K.I.A.';
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%) rotate(-12deg);
  font-family: var(--font-display); font-size: 28px; color: var(--red);
  text-shadow: 0 0 12px rgba(224, 82, 77, 0.6);
  letter-spacing: 0.15em;
}
.unit-card-head {
  padding: 10px 12px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--line);
}
.unit-name {
  font-family: var(--font-display); font-size: var(--fs-base);
  letter-spacing: 0.06em; text-transform: uppercase;
}
.unit-designator {
  font-family: var(--font-body); font-size: var(--fs-sm);
  color: var(--text-dim); letter-spacing: 0.12em;
}
.unit-counter {
  /* the visual "mock counter" — the colored chip showing CV values */
  width: 56px; height: 56px;
  background: var(--bg-3);
  border: 2px solid var(--line-bright);
  display: grid;
  grid-template: 1fr 1fr / 1fr 1fr;
  gap: 1px;
  flex-shrink: 0;
  position: relative;
}
.unit-counter.blue-faction { border-color: var(--blue-deep); }
.unit-counter.red-faction { border-color: var(--red-deep); }
.cv-cell {
  background: var(--bg-2);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-body); font-weight: 700; font-size: var(--fs-sm);
  position: relative;
}
/* Range exponent inside the CV cell per rulebook §4.21 — "the exponent in
   the shape indicates the range of that CV in hexes". Sized small so it reads
   as a subscript, never as part of the CV digit. */
.cv-cell .cv-range {
  position: absolute;
  bottom: 1px;
  right: 2px;
  font-size: 9px;
  font-weight: 700;
  opacity: 0.92;
  line-height: 1;
  letter-spacing: 0;
  pointer-events: none;
}
/* Picker counter is smaller; the range exponent would compete with the CV.
   Drop it there — picker cards display range in the stats line if needed. */
.picker-counter .cv-cell .cv-range { display: none; }
.cv-cell.empty { background: transparent; }
.cv-cell.green { background: var(--cv-green); color: white; }
.cv-cell.red { background: var(--cv-red); color: white; }
.cv-cell.purple { background: var(--cv-purple); color: white; }
.cv-cell.orange { background: var(--cv-orange); color: white; }
.cv-cell.blue { background: var(--cv-blue); color: white; }
.unit-counter.shape-pentagon .cv-cell.purple {
  /* inverted pentagon hint for intercept — visual cue */
  clip-path: polygon(0% 0%, 100% 0%, 100% 70%, 50% 100%, 0% 70%);
}
.unit-card-body {
  padding: 14px;
  display: flex; gap: 14px; align-items: center;
}
.unit-stats {
  flex: 1; display: flex; flex-direction: column; gap: 10px;
}

/* Supply chips per §4.32 — one chip per CV the unit has, colored to match
   that CV's color on the counter. Color identifies which CV's supply this
   is; no text label needed. Each CV has its OWN supply pool, used and
   tracked independently. */
.supply-chips {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.supply-chip {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 3px 9px; min-width: 48px;
  font-family: var(--font-body);
  font-size: var(--fs-sm); font-weight: 700;
  letter-spacing: 0.03em;
  line-height: 1.1;
  color: #fff;
  white-space: nowrap;
}
.supply-chip--ga    { background: var(--cv-green); }
.supply-chip--lrs1  { background: var(--cv-red); }
.supply-chip--lrs2  { background: var(--cv-orange); color: #111; }
.supply-chip--int1  { background: var(--cv-purple); }
.supply-chip--int2  { background: var(--cv-blue); }
.supply-chip--bmd   { background: var(--cv-orange); color: #111; }
.supply-chip--torp  { background: var(--cv-red); }
.supply-chip--rv    { background: var(--cv-blue); border-radius: 999px; }
/* HP is not a CV but the rulebook uses the same color-coded representation:
   a black square (§4.32: "The black square represents the unit's HP").
   Damaged state flips the chip red to flag it visually as harm taken. */
.supply-chip--hp    { background: #000; color: #fff; border: 1px solid var(--text-faint); }
.supply-chip--hp-damaged { background: var(--red); color: #fff; border-color: var(--red); }
.supply-chip.depleted { opacity: 0.4; }
.unit-actions {
  display: flex; gap: 8px; padding: 0 14px 14px;
}
.icon-btn {
  min-width: 44px; height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: var(--bg-3);
  color: var(--text);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  font-family: var(--font-body); font-size: var(--fs-sm);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  transition: all 0.15s;
}
.icon-btn:hover { border-color: var(--yellow); color: var(--yellow); background: var(--bg-2); }
.icon-btn.danger:hover { border-color: var(--red); color: var(--red); }
.icon-btn .ico { font-size: var(--fs-sm); }

/* ============ Forms ============ */
.field {
  display: flex; flex-direction: column; gap: 5px;
}
.field label {
  font-family: var(--font-body); font-size: var(--fs-sm);
  letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--text-dim);
}
.field input, .field select {
  background: var(--bg-0);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 8px 10px;
  font-family: var(--font-body); font-size: var(--fs-xs);
  width: 100%;
}
.field input:focus, .field select:focus {
  outline: none; border-color: var(--yellow);
}
.field input[type=number] { font-variant-numeric: tabular-nums; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}
.form-grid-narrow {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
  gap: 10px;
}

/* ============ Two-column setup ============ */
.battle-cols {
  display: grid; grid-template-columns: 1fr 1fr; gap: 24px;
}
.side-panel {
  background: var(--bg-1);
  border: 1px solid var(--line);
  position: relative;
}
.side-panel.blue { border-top: 3px solid var(--blue); }
.side-panel.red { border-top: 3px solid var(--red); }
.side-head {
  padding: 14px 18px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--line);
}
.side-head .title {
  font-family: var(--font-display); font-size: var(--fs-md);
  letter-spacing: 0.06em;
}
.side-head.blue .title { color: var(--blue); }
.side-head.red .title { color: var(--red); }
.side-head .subtitle {
  font-family: var(--font-display); font-size: var(--fs-sm);
  color: var(--text-dim); letter-spacing: 0.18em; text-transform: uppercase;
}
.side-body { padding: 16px; }
.empty-state {
  border: 1px dashed var(--line-bright);
  padding: 28px;
  text-align: center;
  color: var(--text-dim);
  font-family: var(--font-body); font-size: var(--fs-xs);
  letter-spacing: 0.08em;
}

/* ============ Combat type chooser ============ */
.combat-type-row {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px;
  margin-bottom: 22px;
}
.combat-type-btn {
  background: var(--bg-2);
  border: 1px solid var(--line);
  padding: 18px 14px;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
  position: relative;
}
.combat-type-btn:hover { border-color: var(--line-bright); }
.combat-type-btn.selected {
  border-color: var(--yellow);
  background: linear-gradient(135deg, rgba(240,197,66,0.08), transparent);
  box-shadow: inset 0 0 0 1px rgba(240,197,66,0.15);
}
.combat-type-btn .ctype-name {
  font-family: var(--font-display); font-size: 15px;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text);
}
.combat-type-btn .ctype-desc {
  font-family: var(--font-body); font-size: var(--fs-sm);
  color: var(--text-dim); margin-top: 8px;
  letter-spacing: 0.04em; line-height: 1.4;
}
.combat-type-btn .ctype-rules {
  font-family: var(--font-body); font-size: var(--fs-xs);
  color: var(--text-dim); margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  line-height: 1.5;
}
.combat-type-btn.selected .ctype-rules { color: var(--text); }
.combat-type-btn .ctype-icon {
  position: absolute; top: 14px; right: 14px;
  font-size: 22px; opacity: 0.4;
}
.combat-type-btn.selected .ctype-icon { opacity: 1; color: var(--yellow); }

/* Step sub-section headings — for the Setup step where there are two
   selections in one panel (attacker, combat type). */
.step-section-head {
  display: flex; align-items: center; gap: 12px;
  margin: 6px 0 12px;
  font-family: var(--font-display);
  text-transform: uppercase; letter-spacing: 0.14em;
  color: var(--text-dim);
  font-size: var(--fs-sm);
}
.step-section-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  border: 1px solid var(--line-bright);
  color: var(--yellow);
  font-size: var(--fs-xs); font-weight: 700;
}
.step-section-title { color: var(--text); }

/* Attacker faction picker — two big tactical buttons, color-coded blue / red.
   Either faction can be the attacker (rulebook §3.0 alternating impulses). */
.attacker-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}
.attacker-btn {
  background: var(--bg-2);
  border: 1px solid var(--line);
  padding: 18px 18px;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
  position: relative;
  font-family: var(--font-body);
  color: var(--text-dim);
  display: flex; flex-direction: column; gap: 6px;
}
.attacker-btn:hover { border-color: var(--line-bright); background: var(--bg-3); }
.attacker-btn--blue.selected {
  border-color: var(--blue);
  background: linear-gradient(135deg, rgba(74,144,226,0.12), transparent);
  box-shadow: inset 0 0 0 1px rgba(74,144,226,0.25);
}
.attacker-btn--red.selected {
  border-color: var(--red);
  background: linear-gradient(135deg, rgba(229,90,90,0.12), transparent);
  box-shadow: inset 0 0 0 1px rgba(229,90,90,0.25);
}
.attacker-btn .atk-tag {
  align-self: flex-start;
  font-family: var(--font-display);
  font-size: var(--fs-xs); font-weight: 700;
  letter-spacing: 0.18em;
  padding: 3px 10px;
  color: #fff;
}
.atk-tag--blue { background: var(--blue); }
.atk-tag--red  { background: var(--red); }
.attacker-btn .atk-name {
  font-family: var(--font-display); font-size: var(--fs-md);
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text);
}
.attacker-btn--blue.selected .atk-name { color: var(--blue); }
.attacker-btn--red.selected .atk-name  { color: var(--red); }
.attacker-btn .atk-desc {
  font-family: var(--font-body); font-size: var(--fs-sm);
  color: var(--text-dim); letter-spacing: 0.02em;
}

/* Scenario picker (step 1) — visually rhymes with combat-type-btn but denser
   because each card lists multiple Task Forces and their unit counts. */
.scenario-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 14px;
}
.scenario-card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  padding: 16px 18px 18px;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
  position: relative;
  font-family: var(--font-body);
  color: var(--text-dim);
  display: flex; flex-direction: column; gap: 10px;
}
.scenario-card:hover { border-color: var(--line-bright); background: var(--bg-3); }
.scenario-card.selected {
  border-color: var(--yellow);
  background: linear-gradient(135deg, rgba(240,197,66,0.08), transparent);
  box-shadow: inset 0 0 0 1px rgba(240,197,66,0.15);
}
.scenario-card .scn-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
}
.scenario-card .scn-name {
  font-family: var(--font-display); font-size: var(--fs-md);
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text);
}
.scenario-card .scn-diff {
  font-family: var(--font-body); font-size: var(--fs-xs);
  letter-spacing: 0.1em; text-transform: uppercase;
  padding: 2px 8px;
  border: 1px solid var(--line-bright);
  color: var(--text-dim);
  flex-shrink: 0;
}
.scenario-card .scn-diff--low    { color: var(--cv-green);   border-color: var(--cv-green); }
.scenario-card .scn-diff--medium { color: var(--yellow);     border-color: var(--yellow); }
.scenario-card .scn-diff--high   { color: var(--red);        border-color: var(--red); }
.scenario-card .scn-meta {
  font-size: var(--fs-xs); letter-spacing: 0.05em;
  color: var(--text-faint); text-transform: uppercase;
}
.scenario-card .scn-summary {
  font-size: var(--fs-sm); line-height: 1.5;
  color: var(--text-dim);
}
.scenario-card .scn-tfs {
  display: flex; flex-direction: column; gap: 6px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
}
.scenario-card .scn-tf {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline;
  font-size: var(--fs-xs);
  letter-spacing: 0.04em;
}
.scenario-card .scn-tf-side {
  font-family: var(--font-display); text-transform: uppercase;
  letter-spacing: 0.12em; min-width: 42px;
}
.scenario-card .scn-tf--blue .scn-tf-side { color: var(--blue); }
.scenario-card .scn-tf--red  .scn-tf-side { color: var(--red); }
.scenario-card .scn-tf-name {
  color: var(--text-dim);
}
.scenario-card .scn-tf-name + .scn-tf-name { padding-left: 4px; }

/* Combat type breadcrumb banner (shown above Deploy step) */
.combat-type-banner {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px;
  background: linear-gradient(90deg, rgba(240,197,66,0.06), transparent);
  border: 1px solid var(--line);
  border-left: 3px solid var(--yellow);
  margin-bottom: 22px;
}
.combat-type-banner .ctb-left {
  display: flex; align-items: center; gap: 16px;
}
.combat-type-banner .ctb-icon {
  font-size: 28px; color: var(--yellow);
  line-height: 1;
}
.combat-type-banner .ctb-label {
  font-family: var(--font-display); font-size: var(--fs-sm);
  letter-spacing: 0.2em; color: var(--text-dim);
  text-transform: uppercase;
}
.combat-type-banner .ctb-name {
  font-family: var(--font-display); font-size: 22px;
  letter-spacing: 0.04em; color: var(--text);
  margin-top: 2px;
}

/* Filter hint at top of unit picker modal */
.filter-hint {
  background: rgba(74,143,231,0.06);
  border-left: 2px solid var(--blue);
  padding: 10px 14px;
  margin-bottom: 18px;
  font-family: var(--font-body); font-size: var(--fs-sm);
  color: var(--text-dim);
  line-height: 1.5;
}
.filter-hint strong { color: var(--yellow); font-weight: 600; }

/* ============ Modifier toggles ============ */
.mod-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}
.mod-card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  padding: 14px;
}
.mod-title {
  font-family: var(--font-display); font-size: 15px;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text);
  margin-bottom: 10px;
  display: flex; align-items: center; gap: 8px;
  /* Subtle cue that the title has a hover tooltip with the rule text */
  cursor: help;
  border-bottom: 1px dotted transparent;
}
.mod-title:hover { border-bottom-color: var(--text-faint); }
.mod-title .badge {
  font-family: var(--font-body); font-size: var(--fs-sm);
  background: var(--bg-3); border: 1px solid var(--line);
  padding: 2px 7px; color: var(--text-dim);
  letter-spacing: 0.08em;
}
.seg-control {
  display: flex; border: 1px solid var(--line);
}
.seg-control button {
  flex: 1; padding: 9px 6px; background: var(--bg-1);
  border: none; color: var(--text-dim);
  font-family: var(--font-body); font-size: var(--fs-sm);
  letter-spacing: 0.06em; text-transform: uppercase;
  cursor: pointer;
  border-right: 1px solid var(--line);
  white-space: nowrap;
  min-width: 0;
}
.seg-control button:last-child { border-right: none; }
.seg-control button.active {
  background: var(--yellow); color: var(--bg-0); font-weight: 700;
}
.seg-control button:hover:not(.active) { background: var(--bg-3); color: var(--text); }
.checkbox-row {
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  padding: 8px 0;
}
.checkbox-box {
  width: 18px; height: 18px;
  border: 1px solid var(--line-bright);
  background: var(--bg-1);
  display: flex; align-items: center; justify-content: center;
  color: var(--yellow); font-weight: 700;
  flex-shrink: 0;
}
.checkbox-row input { display: none; }
.checkbox-row input:checked + .checkbox-box::before { content: '✓'; }
.checkbox-row input:checked + .checkbox-box { border-color: var(--yellow); background: rgba(240,197,66,0.1); }
.checkbox-row .lbl {
  font-family: var(--font-body); font-size: var(--fs-xs);
  color: var(--text);
  letter-spacing: 0.04em;
}
.number-stepper {
  display: inline-flex; align-items: center; border: 1px solid var(--line);
  background: var(--bg-1);
  overflow: hidden;
}
.number-stepper button {
  background: transparent; border: none; color: var(--text);
  width: 32px; height: 32px; cursor: pointer;
  font-family: var(--font-body); font-size: var(--fs-base);
  font-weight: 600;
}
.number-stepper button:hover:not(:disabled) { background: var(--yellow); color: var(--bg-0); }
.number-stepper button:disabled { opacity: 0.3; cursor: not-allowed; }
.number-stepper .val {
  min-width: 36px; text-align: center;
  font-family: var(--font-body); font-size: 15px;
  font-weight: 600; color: var(--text);
  border-left: 1px solid var(--line); border-right: 1px solid var(--line);
  padding: 7px 0; background: var(--bg-2);
}
/* Larger steppers inside the allocation matrix cells (most important UI) */
.alloc-cell .number-stepper button {
  width: 40px; height: 40px; font-size: var(--fs-lg);
}
.alloc-cell .number-stepper .val {
  min-width: 44px; padding: 9px 0; font-size: 17px;
}

/* ============ Allocation Step ============ */
.alloc-summary {
  background: var(--bg-2);
  border: 1px solid var(--line);
  padding: 16px;
  margin-bottom: 18px;
  display: flex; gap: 24px; flex-wrap: wrap;
}
.alloc-meta {
  font-family: var(--font-body); font-size: var(--fs-sm);
  color: var(--text-dim); letter-spacing: 0.1em;
}
.alloc-meta .v { color: var(--text); font-weight: 700; }
.alloc-meta .v.neg { color: var(--red); }
.alloc-meta .v.pos { color: var(--green); }

.alloc-matrix-wrap {
  overflow-x: auto;
}
.alloc-matrix {
  width: 100%;
  border-collapse: collapse;
}
.alloc-matrix th, .alloc-matrix td {
  border: 1px solid var(--line);
  padding: 8px;
  vertical-align: middle;
}
.alloc-matrix th {
  background: var(--bg-2);
  font-family: var(--font-body); font-size: var(--fs-xs);
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-dim);
  text-align: left;
  font-weight: 500;
}
.alloc-matrix th.target-th {
  text-align: center;
  min-width: 130px;
}
.alloc-matrix th.target-th.side-blue { border-top: 2px solid var(--blue); }
.alloc-matrix th.target-th.side-red { border-top: 2px solid var(--red); }
.alloc-matrix td.attacker-td {
  background: var(--bg-2);
  min-width: 200px;
}
.alloc-matrix td.attacker-td.side-blue { border-left: 2px solid var(--blue); }
.alloc-matrix td.attacker-td.side-red { border-left: 2px solid var(--red); }
.alloc-attacker-info { display: flex; align-items: center; gap: 10px; }
.alloc-attacker-info .unit-counter { width: 42px; height: 42px; }
.alloc-attacker-info .nm { font-family: var(--font-body); font-size: 15px; letter-spacing: 0.04em; color: var(--text); }
.alloc-attacker-info .dg { font-family: var(--font-body); font-size: var(--fs-sm); color: var(--text-dim); }
.alloc-target-th-content { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.alloc-target-th-content .nm { font-family: var(--font-body); font-size: var(--fs-xs); color: var(--text); }
.alloc-target-th-content .hp { font-family: var(--font-body); font-size: var(--fs-sm); color: var(--text-dim); }
.alloc-cell { text-align: center; }
.cv-pick {
  display: flex; gap: 4px; justify-content: center; margin-bottom: 4px;
}
.cv-pick button {
  width: 22px; height: 22px; padding: 0;
  border: 1px solid var(--line);
  background: var(--bg-3);
  color: var(--text); font-family: var(--font-body); font-size: var(--fs-sm);
  cursor: pointer;
}
.cv-pick button.active.green { background: var(--cv-green); border-color: var(--cv-green); }
.cv-pick button.active.red { background: var(--cv-red); border-color: var(--cv-red); }
.cv-pick button.active.orange { background: var(--cv-orange); border-color: var(--cv-orange); }
.cv-pick button.active.purple { background: var(--cv-purple); border-color: var(--cv-purple); }
.cv-pick button.active.blue { background: var(--cv-blue); border-color: var(--cv-blue); }
.cv-pick button:disabled { opacity: 0.25; cursor: not-allowed; }
.alloc-cell .number-stepper { margin: 0 auto; }

.alloc-mode-toggle {
  display: inline-flex; border: 1px solid var(--line); margin-bottom: 16px;
}
.alloc-mode-toggle button {
  padding: 9px 18px; background: var(--bg-2); border: none;
  color: var(--text-dim);
  font-family: var(--font-body); font-size: var(--fs-xs); letter-spacing: 0.08em; text-transform: uppercase;
  cursor: pointer;
  border-right: 1px solid var(--line);
}
.alloc-mode-toggle button:last-child { border-right: none; }
.alloc-mode-toggle button.active {
  background: var(--yellow); color: var(--bg-0); font-weight: 700;
}

/* Combined attacker+defender allocation for Ground Assault */
.alloc-section { margin-bottom: 24px; }
.alloc-section-head {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 12px;
  padding: 10px 14px;
  background: var(--bg-2);
  border: 1px solid var(--line);
}
.alloc-section-head.blue { border-left: 3px solid var(--blue); }
.alloc-section-head.red  { border-left: 3px solid var(--red); }
.alloc-section-title {
  font-family: var(--font-display); font-size: var(--fs-md);
  letter-spacing: 0.04em; color: var(--text);
}
.alloc-section-head.blue .alloc-section-title { color: var(--blue); }
.alloc-section-head.red  .alloc-section-title { color: var(--red); }
.alloc-section-sub {
  font-family: var(--font-body); font-size: var(--fs-sm);
  color: var(--text-dim); margin-top: 4px;
  letter-spacing: 0.04em; line-height: 1.4;
}
.ready-tick {
  font-family: var(--font-body); font-size: var(--fs-sm);
  letter-spacing: 0.12em; color: var(--green);
  margin-left: 10px; font-weight: 700;
}
.ready-warn {
  font-family: var(--font-body); font-size: var(--fs-sm);
  letter-spacing: 0.12em; color: var(--orange);
  margin-left: 10px; font-weight: 700;
  animation: pendingPulse 1.4s infinite;
}

/* ============ Dice Roll ============ */
.roll-group {
  background: var(--bg-1); border: 1px solid var(--line);
  padding: 14px;
}
.roll-group-head {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 12px;
}
.roll-group-head .arrow {
  color: var(--yellow); font-size: var(--fs-sm);
}
.roll-group-head .nm { font-family: var(--font-body); font-size: 15px; letter-spacing: 0.04em; color: var(--text); }
.roll-group-head .cv-pill {
  margin-left: auto;
  font-family: var(--font-body); font-size: var(--fs-sm);
  background: var(--bg-3); padding: 4px 10px;
  border: 1px solid var(--line);
  letter-spacing: 0.08em;
}
.roll-group-head .cv-pill .cv-color {
  display: inline-block; width: 8px; height: 8px; margin-right: 6px; vertical-align: middle;
}
.phase-tag {
  font-family: var(--font-body); font-size: var(--fs-sm);
  letter-spacing: 0.12em; text-transform: uppercase;
  padding: 3px 8px; border: 1px solid var(--line);
  background: var(--bg-3); color: var(--text-dim);
}
.phase-tag.phase-detect { color: var(--blue); border-color: var(--blue-deep); }
.phase-tag.phase-asw { color: var(--purple); border-color: var(--purple); }
.phase-tag.phase-torp { color: var(--red); border-color: var(--red-deep); }
.cv-color.green { background: var(--cv-green); }
.cv-color.red { background: var(--cv-red); }
.cv-color.orange { background: var(--cv-orange); }
.cv-color.purple { background: var(--cv-purple); }
.cv-color.blue { background: var(--cv-blue); }
.dice-row {
  display: flex; flex-wrap: wrap; gap: 20px 22px;
  align-items: center;
  padding: 8px 4px;
}
.die {
  /* The face is rotated 45° so the diamond's visible diagonal extends beyond the 52px box.
     Reserve ~60px of horizontal space and add small breathing room so neighbours don't clip. */
  width: 52px; height: 52px;
  flex: 0 0 52px;
  position: relative;
  perspective: 200px;
  /* prevent any inherited text-decoration from bleeding visually between dice */
  text-decoration: none;
}
/* Die color = faction (blue/red) per the army's physical dice color */
.die-face {
  width: 100%; height: 100%;
  background: var(--bg-3);
  border: 2px solid var(--line-bright);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-body); font-size: var(--fs-lg); font-weight: 700;
  color: var(--text);
  transform: rotate(45deg);
  position: relative;
  transition: all 0.3s;
}
.die-face::before {
  content: ''; position: absolute; inset: 4px;
  border: 1px solid var(--line);
}
.die-face span {
  transform: rotate(-45deg);
  position: relative; z-index: 1;
}
/* Faction-tinted base (before resolution) */
.die.faction-blue .die-face { background: rgba(74,143,231,0.18);  border-color: var(--blue); }
.die.faction-red  .die-face { background: rgba(224,82,77,0.18);   border-color: var(--red); }
.die.rolling .die-face {
  animation: dieRoll 0.6s linear infinite;
}
@keyframes dieRoll {
  0% { transform: rotate(45deg) scale(1); }
  25% { transform: rotate(135deg) scale(1.05); }
  50% { transform: rotate(225deg) scale(0.95); }
  75% { transform: rotate(315deg) scale(1.05); }
  100% { transform: rotate(405deg) scale(1); }
}
/* Hit: intensify to full faction color */
.die.hit.faction-blue .die-face { background: var(--blue);  color: white; box-shadow: 0 0 14px var(--blue-glow); border-color: var(--blue); }
.die.hit.faction-red  .die-face { background: var(--red);   color: white; box-shadow: 0 0 14px var(--red-glow); border-color: var(--red); }
/* Miss: dim with strikethrough */
.die.miss .die-face {
  opacity: 0.3;
  filter: grayscale(0.5);
}
.die.miss .die-face span { text-decoration: line-through; }
.die-result-bar {
  margin-left: auto;
  display: flex; gap: 14px; align-items: center;
  padding-left: 18px;
  border-left: 1px solid var(--line);
}
.die-result-bar .res-block {
  text-align: center; min-width: 64px;
  padding: 4px 10px;
}
.die-result-bar .res-block .v {
  font-family: var(--font-display); font-size: 36px;
  line-height: 1; letter-spacing: 0.04em;
}
.die-result-bar .res-block .l {
  font-family: var(--font-body); font-size: var(--fs-sm);
  letter-spacing: 0.18em; margin-top: 4px;
  color: var(--text-dim);
}
.die-result-bar .res-block.hits .v { color: var(--green); text-shadow: 0 0 12px rgba(79,217,122,0.45); }
.die-result-bar .res-block.hits.zero .v { color: var(--text-faint); text-shadow: none; }
.die-result-bar .res-block.misses .v { color: var(--text-dim); }

/* Allocate step — mutual exchange (ground): attacker matrix left, defender right. */
.alloc-cols {
  display: grid; grid-template-columns: 1fr 1fr; gap: 18px;
  align-items: start;
}
.alloc-cols .alloc-section { margin: 0; }

/* ============ Resolve Step ============ */
/* Strict two-column attacker/defender layout — also used by the Roll step
   so the dice view follows the same left/right convention. */
.resolve-cols {
  display: grid; grid-template-columns: 1fr 1fr; gap: 18px;
  margin-bottom: 18px;
  align-items: start;
}
.resolve-col { display: flex; flex-direction: column; gap: 12px; }
.resolve-col-head {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  font-family: var(--font-body);
}
.resolve-col-head.blue { border-left: 3px solid var(--blue); }
.resolve-col-head.red  { border-left: 3px solid var(--red); }
.resolve-col-head .role-label {
  font-size: var(--fs-sm); font-weight: 700;
  letter-spacing: 0.12em; color: var(--text);
}
.resolve-col-head .faction-label {
  font-size: var(--fs-sm); color: var(--text-dim);
  letter-spacing: 0.06em;
  margin-left: auto;
}
.resolve-empty {
  padding: 18px;
  background: var(--bg-2);
  border: 1px dashed var(--line);
  text-align: center;
  font-family: var(--font-body); font-size: var(--fs-sm);
  letter-spacing: 0.1em; color: var(--text-faint);
}
.damage-card {
  background: var(--bg-2); border: 1px solid var(--line);
  padding: 16px;
}
.damage-card.has-damage { border-color: var(--orange); }
.damage-card.killed { border-color: var(--red); background: linear-gradient(135deg, rgba(224,82,77,0.06), var(--bg-2)); }
.damage-card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.damage-card-head .nm { font-family: var(--font-body); font-size: var(--fs-base); letter-spacing: 0.04em; color: var(--text); }
.damage-card-head .dg { font-family: var(--font-body); font-size: var(--fs-sm); color: var(--text-dim); }
.damage-card-head .badge-pill {
  margin-left: auto;
  font-family: var(--font-body); font-size: var(--fs-sm);
  padding: 3px 9px; letter-spacing: 0.08em;
}
.badge-pill.killed { background: var(--red); color: white; }
.badge-pill.hit { background: var(--orange); color: var(--bg-0); }
.badge-pill.safe { background: var(--bg-3); color: var(--text-dim); border: 1px solid var(--line); }
.hp-bar {
  display: flex; gap: 3px; margin: 8px 0;
}
.hp-pip {
  flex: 1; height: 14px;
  background: var(--bg-1); border: 1px solid var(--line);
  position: relative;
}
.hp-pip.full { background: var(--green-deep); border-color: var(--green); }
.hp-pip.lost { background: var(--bg-1); border-color: var(--line); }
.hp-pip.pending {
  background: var(--orange); border-color: var(--orange);
  animation: pendingPulse 1s infinite;
}
@keyframes pendingPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.damage-card.protected { border-color: var(--green); background: linear-gradient(135deg, rgba(108,179,118,0.06), var(--bg-2)); }
.mildec-section {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  font-family: var(--font-body); font-size: var(--fs-sm);
  color: var(--text-dim);
}

/* Resolve step — per-target MILDEC absorption stepper row. Each MILDEC
   absorbs 1 HP; the stepper sets how many of the incoming hits get
   absorbed for this target. Bounded by min(hits, free_pool). */
.mildec-stepper-row {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: 12px;
  font-family: var(--font-body); font-size: var(--fs-sm);
  color: var(--text);
}
.mildec-stepper-row .lbl { letter-spacing: 0.08em; }

.damage-card-head-text { display: flex; flex-direction: column; }
.damage-card-head-text .nm { display: flex; align-items: center; gap: 8px; }

/* ============ After-Action (Result step) ============ */
/* One card per affected unit (or sacrificed MILDEC), arranged in the same
   2-column attacker/defender split used by Adjust / Allocate / Roll /
   Resolve. Each card lists the physical changes to apply at the table; a
   checkbox per row lets the player tick off as they go. */
.action-empty {
  padding: 18px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  text-align: center;
}
.action-card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  padding: 14px;
}
.action-card--blue { border-left: 3px solid var(--blue); }
.action-card--red  { border-left: 3px solid var(--red); }
.action-card--mildec { background: linear-gradient(135deg, rgba(240,197,66,0.04), var(--bg-2)); }
.action-card-head {
  display: flex; align-items: center; gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px dashed var(--line);
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.action-card-dg {
  font-family: var(--font-body); font-size: var(--fs-base);
  font-weight: 700; letter-spacing: 0.04em;
  color: var(--text);
}
.action-card-nm {
  font-family: var(--font-body); font-size: var(--fs-sm);
  color: var(--text-dim); letter-spacing: 0.03em;
}
.action-rows {
  list-style: none;
  margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 2px;
}
.action-row {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}
.action-row:first-child { border-top: 0; }
.action-check {
  display: inline-flex;
  margin-top: 2px;
  cursor: pointer;
}
.action-check input { position: absolute; opacity: 0; pointer-events: none; }
.action-check span {
  width: 18px; height: 18px;
  background: var(--bg-1);
  border: 1px solid var(--text-dim);
  display: inline-block;
  position: relative;
}
.action-check input:checked + span {
  background: var(--green-deep);
  border-color: var(--green);
}
.action-check input:checked + span::after {
  content: '✓';
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 13px; font-weight: 700;
}
.action-check:has(input:checked) ~ .action-text { opacity: 0.5; text-decoration: line-through; }
.action-text {
  flex: 1;
  font-family: var(--font-body); font-size: var(--fs-sm);
  color: var(--text);
}
.action-text .num {
  font-family: var(--font-body); font-weight: 700;
  background: var(--bg-1); padding: 1px 6px;
  border: 1px solid var(--line);
  font-size: var(--fs-xs);
}
.action-text .action-target {
  font-weight: 700; color: var(--text);
}
.side-tag {
  font-family: var(--font-body); font-weight: 700; font-size: var(--fs-xs);
  letter-spacing: 0.1em;
  padding: 1px 6px;
  border: 1px solid;
}
.side-tag.blue { color: var(--blue); border-color: var(--blue); }
.side-tag.red  { color: var(--red);  border-color: var(--red); }

/* ============ Result ============ */
.result-banner {
  background: linear-gradient(135deg, var(--bg-2), var(--bg-1));
  border: 1px solid var(--line);
  border-top: 3px solid var(--yellow);
  padding: 28px 24px;
  margin-bottom: 22px;
  text-align: center;
  position: relative;
}
.verdict-line {
  font-family: var(--font-display);
  font-size: 38px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--yellow);
  text-shadow: 0 0 24px rgba(240,197,66,0.22);
}
.verdict-compare {
  display: flex; align-items: center; justify-content: center;
  gap: 24px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
}
.verdict-side {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-body); font-size: var(--fs-sm);
  letter-spacing: 0.08em;
}
.verdict-role { font-weight: 600; color: var(--text); }
.verdict-loss { color: var(--orange); font-family: var(--font-mono); }
.verdict-loss--none { color: var(--text-faint); }
.verdict-vs {
  font-family: var(--font-mono); color: var(--text-faint);
  font-size: var(--fs-xs); letter-spacing: 0.2em;
}
.verdict-sub {
  font-family: var(--font-body); font-size: var(--fs-xs);
  color: var(--text-dim); letter-spacing: 0.2em;
  margin-top: 14px; text-transform: uppercase;
}

.result-stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px; margin-bottom: 22px;
}
.stat-box {
  background: var(--bg-2); border: 1px solid var(--line);
  padding: 18px 14px;
  text-align: center;
  position: relative;
}
.stat-box::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: var(--line-bright);
}
.stat-box .lbl {
  font-family: var(--font-body); font-size: var(--fs-sm); letter-spacing: 0.16em;
  color: var(--text-dim); text-transform: uppercase;
}
.stat-box .val {
  font-family: var(--font-display); font-size: 44px;
  margin-top: 8px; line-height: 1;
}
.stat-box.blue::before { background: var(--blue); box-shadow: 0 0 8px var(--blue-glow); }
.stat-box.red::before { background: var(--red); box-shadow: 0 0 8px var(--red-glow); }
.stat-box.green::before { background: var(--green); box-shadow: 0 0 8px var(--green-glow); }
.stat-box.yellow::before { background: var(--yellow); box-shadow: 0 0 8px rgba(240,197,66,0.3); }
.stat-box.blue .val { color: var(--blue); }
.stat-box.red .val { color: var(--red); }
.stat-box.green .val { color: var(--green); }
.stat-box.yellow .val { color: var(--yellow); }

/* ============ Misc ============ */
.footer-nav {
  margin-top: 26px; display: flex; justify-content: space-between; gap: 12px;
}
.info-line {
  font-family: var(--font-body); font-size: var(--fs-sm); color: var(--text-dim);
  letter-spacing: 0.08em; margin-top: 12px;
}
.tag {
  display: inline-block;
  font-family: var(--font-body); font-size: var(--fs-sm);
  padding: 2px 7px;
  background: var(--bg-3); border: 1px solid var(--line);
  letter-spacing: 0.1em;
  margin-right: 4px;
}
.tag.blue { background: var(--blue-deep); color: white; border-color: var(--blue); }
.tag.red { background: var(--red-deep); color: white; border-color: var(--red); }
.tag.green { background: var(--green-deep); color: white; border-color: var(--green); }
.tag.orange { background: var(--cv-orange); color: white; border-color: var(--cv-orange); }
.tag.purple { background: var(--cv-purple); color: white; border-color: var(--cv-purple); }

/* Modal */
.modal-bg {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
}
.modal {
  background: var(--bg-1);
  border: 1px solid var(--yellow);
  width: 92%; max-width: 1100px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}
/* Smaller modals (Edit Unit) use a tighter cap via .modal--narrow */
.modal.modal--narrow { max-width: 720px; }
.modal-head {
  padding: 16px 20px; border-bottom: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: center;
  background: linear-gradient(90deg, var(--bg-2), transparent);
}
.modal-body { padding: 20px; }

/* Unit picker (Deploy modal) cards — show counter visual alongside text */
.picker-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px; margin-top: 16px;
}
/* MILDEC row only has 2 templates (ground + naval), so pin to 2 columns
   instead of auto-fit (which would leave an empty phantom slot on wide
   viewports). */
.picker-grid--mildec {
  grid-template-columns: repeat(2, 1fr);
}
.picker-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--bg-2); border: 1px solid var(--line);
  padding: 12px 14px; cursor: pointer; text-align: left;
  transition: all 0.15s;
}
.picker-card:hover:not(:disabled) { border-color: var(--yellow); background: var(--bg-3); }
.picker-card:disabled { cursor: not-allowed; }
.picker-card.picker-card--disabled {
  opacity: 0.4;
  background: var(--bg-1);
}
.picker-card.picker-card--disabled:hover { border-color: var(--line); background: var(--bg-1); }
.picker-card.picker-card--deployed {
  opacity: 0.55;
  background: var(--bg-1);
  border-color: var(--line);
}
.picker-card.picker-card--deployed::before {
  content: 'DEPLOYED';
  position: absolute;
  top: 4px; right: 4px;
  font-family: var(--font-display); font-size: 9px;
  letter-spacing: 0.15em; color: var(--text-faint);
  background: var(--bg-2); padding: 1px 4px;
}
/* Multi-select state: highlighted border + checkmark badge. */
.picker-card.picker-card--selected {
  border-color: var(--yellow);
  background: rgba(247, 184, 1, 0.06);
  box-shadow: inset 0 0 0 1px var(--yellow);
}
.picker-card .picker-check {
  position: absolute;
  top: 6px; right: 6px;
  font-family: var(--font-display);
  font-size: var(--fs-sm); font-weight: 700;
  color: var(--bg-0); background: var(--yellow);
  padding: 2px 7px; letter-spacing: 0.05em;
  line-height: 1;
}
.picker-card .picker-decr {
  position: absolute;
  bottom: 6px; right: 6px;
  width: 22px; height: 22px;
  border: 1px solid var(--line-bright);
  background: var(--bg-2);
  color: var(--text);
  font-family: var(--font-display); font-size: var(--fs-md); font-weight: 700;
  line-height: 1; padding: 0;
  cursor: pointer;
}
.picker-card .picker-decr:hover { background: var(--bg-3); border-color: var(--yellow); color: var(--yellow); }
/* Modal footer for the new multi-select Confirm/Cancel row. */
.modal-foot {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  background: var(--bg-1);
  gap: 12px;
}
.picker-card { position: relative; }
.picker-card__text { flex: 1; min-width: 0; }
.picker-card__designator {
  font-family: var(--font-display); font-size: var(--fs-sm);
  font-weight: 700; letter-spacing: var(--ls-wider);
  text-transform: uppercase; color: var(--yellow);
  line-height: 1.2;
}
.picker-card--disabled .picker-card__designator,
.picker-card--deployed .picker-card__designator { color: var(--text-faint); }
.picker-card--locked {
  opacity: 0.35;
  cursor: not-allowed;
  background: var(--bg-1);
}
.picker-card--locked:hover { border-color: var(--line); background: var(--bg-1); }
.picker-card__name {
  font-family: var(--font-body); font-size: var(--fs-sm);
  color: var(--text-dim); margin-top: 4px;
  letter-spacing: 0.02em;
  line-height: 1.25;
}
.picker-card__stats {
  font-family: var(--font-body); font-size: var(--fs-xs);
  color: var(--text-faint); margin-top: 6px; letter-spacing: 0.04em;
  line-height: 1.4;
}
.picker-card__reason {
  font-family: var(--font-body); font-size: var(--fs-xs);
  color: var(--orange); margin-top: 4px;
  letter-spacing: 0.04em; font-style: italic;
}
.picker-counter {
  flex-shrink: 0;
  width: 48px; height: 48px;
}
.picker-counter .cv-cell { font-size: var(--fs-sm); }

/* Task Force grouping — each TF is a card in the deploy modal */
.tf-section {
  margin-bottom: 22px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--line-bright);
  padding: 16px 18px 18px;
}
.tf-section--blue { border-left-color: var(--blue); }
.tf-section--red  { border-left-color: var(--red); }
.tf-section--neutral { border-left-color: var(--orange); }
.tf-section:last-child { margin-bottom: 0; }
.tf-header {
  display: flex; align-items: center; gap: 12px;
  font-family: var(--font-display); font-size: var(--fs-md);
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text);
  padding-bottom: 10px; margin-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.tf-header .tf-bar {
  width: 5px; height: 22px; flex-shrink: 0;
}
.tf-header.blue { color: var(--blue); }
.tf-header.blue .tf-bar { background: var(--blue); box-shadow: 0 0 8px var(--blue-glow); }
.tf-header.red { color: var(--red); }
.tf-header.red .tf-bar { background: var(--red); box-shadow: 0 0 8px var(--red-glow); }
.tf-header.neutral { color: var(--text-dim); }
.tf-header.neutral .tf-bar { background: var(--line-bright); }
.tf-header .tf-sub {
  margin-left: auto;
  font-family: var(--font-body); font-size: var(--fs-sm);
  color: var(--text-dim); letter-spacing: 0.1em;
  text-transform: uppercase;
}

@media (max-width: 900px) {
  .battle-cols { grid-template-columns: 1fr; }
  .resolve-grid { grid-template-columns: 1fr; }
  .combat-type-row { grid-template-columns: 1fr; }
  main { padding: 16px; }
  .topbar { padding: 14px 16px; flex-wrap: wrap; gap: 12px; }
  .stepper { padding: 12px 16px; }
  .step-label { display: none; }
}

/* ============ Adjust step ============ */
/* Per-unit cards in the attacker/defender columns. Each card carries an
   HP stepper and one row per present CV slot (CV value + supply remaining).
   Defaults come from the unit's current values; edits mutate the unit
   object directly so allocation / rolls / damage use the adjusted state. */
.adjust-card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  padding: 14px;
}
.adjust-card--blue { border-left: 3px solid var(--blue); }
.adjust-card--red  { border-left: 3px solid var(--red); }
.adjust-card-head {
  display: flex; align-items: center; gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px dashed var(--line);
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.adjust-card-dg {
  font-family: var(--font-body); font-size: var(--fs-base);
  font-weight: 700; letter-spacing: 0.04em;
  color: var(--text);
}
.adjust-card-nm {
  font-family: var(--font-body); font-size: var(--fs-sm);
  color: var(--text-dim); letter-spacing: 0.03em;
}

.adjust-row {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 0;
}
.adjust-field {
  display: flex; align-items: center; gap: 8px;
}
.adjust-field-label {
  font-family: var(--font-body); font-size: var(--fs-xs);
  letter-spacing: 0.12em; color: var(--text-faint);
  min-width: 24px;
}
.adjust-field-max {
  font-family: var(--font-mono); font-size: var(--fs-xs);
  color: var(--text-faint);
}
.adjust-infinity {
  font-family: var(--font-mono); font-size: var(--fs-md);
  color: var(--text-dim);
  padding: 0 6px;
}

.adjust-cvs {
  display: flex; flex-direction: column; gap: 4px;
  margin-top: 8px;
}
.adjust-cv-row {
  display: grid;
  grid-template-columns: 36px 60px 1fr 1fr;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  border-top: 1px solid var(--line);
}
.adjust-cv-label {
  font-family: var(--font-body); font-size: var(--fs-sm);
  font-weight: 600; letter-spacing: 0.06em;
  color: var(--text);
}

/* ─── Modified-value highlighting (Adjust step) ────────────────────── */
/* Yellow accent on any stepper whose current value ≠ template default.
   The ↺ reset icon appears alongside so the user can undo a single edit
   without remembering what the original was. */
.number-stepper.modified {
  border-color: var(--yellow);
  box-shadow: inset 0 0 0 1px var(--yellow);
}
.number-stepper.modified .val { color: var(--yellow); font-weight: 700; }
.adjust-reset {
  background: none; border: 1px solid var(--line);
  color: var(--text-dim);
  width: 24px; height: 24px;
  font-size: 13px; line-height: 1;
  cursor: pointer;
  padding: 0;
  transition: all 120ms ease;
}
.adjust-reset:hover { border-color: var(--yellow); color: var(--yellow); }


/* ============ History view (full page) ============ */
/* Toolbar with back / count / search / clear-all on row 1; filter chips on row 2.
   Below: list of round rows, each with a header (always visible, stats at-a-glance)
   and a detail block (hidden until expanded). Yellow accents on selected filter
   chips keep the selection-vocabulary consistent with the rest of the app. */
.history-view {
  display: flex; flex-direction: column; gap: 14px;
  max-width: 1200px;
  margin: 0 auto;
}
.history-toolbar {
  display: flex; flex-direction: column; gap: 10px;
  padding: 14px 16px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.history-toolbar-row {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.history-count {
  font-family: var(--font-body); font-size: var(--fs-sm);
  color: var(--text-dim); letter-spacing: 0.06em;
  margin-right: auto;
}
.history-search {
  flex: 1 1 260px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  padding: 7px 10px;
  font-family: var(--font-body); font-size: var(--fs-sm);
  color: var(--text);
}
.history-search:focus { outline: none; border-color: var(--yellow); }
.history-chips {
  gap: 6px;
}
.filter-chip-group {
  display: flex; gap: 2px;
  padding: 2px;
  background: var(--bg-1);
  border: 1px solid var(--line);
}
.filter-chip {
  background: none; border: none;
  padding: 5px 11px;
  font-family: var(--font-body); font-size: var(--fs-xs);
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-dim);
  cursor: pointer;
  white-space: nowrap;
}
.filter-chip:hover:not(.active) { color: var(--text); background: var(--bg-2); }
.filter-chip.active {
  background: var(--yellow); color: var(--bg-0); font-weight: 700;
}

/* ─── List ─── */
.history-list { display: flex; flex-direction: column; gap: 8px; }
.history-empty {
  padding: 60px 20px;
  text-align: center;
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--text-faint);
}
.history-empty-icon { font-size: 48px; opacity: 0.4; margin-bottom: 12px; }
.history-empty-title {
  font-family: var(--font-display); font-size: var(--fs-base);
  letter-spacing: 0.12em; color: var(--text-dim); margin-bottom: 6px;
}
.history-empty-sub {
  font-family: var(--font-body); font-size: var(--fs-sm); letter-spacing: 0.04em;
  color: var(--text-faint); max-width: 480px; margin: 0 auto;
}

/* ─── Per-round row ─── */
.hist-row {
  background: var(--bg-2);
  border: 1px solid var(--line);
}
.hist-row-head {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  cursor: pointer;
}
.hist-row-caret {
  font-size: 11px;
  color: var(--text-faint);
  transition: transform 120ms ease;
}
.hist-row.is-expanded .hist-row-caret { transform: rotate(90deg); }
.hist-row-headline {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-family: var(--font-body); font-size: var(--fs-sm); letter-spacing: 0.04em;
}
.hist-row-when { color: var(--text-faint); font-family: var(--font-mono); }
.hist-row-scn  { color: var(--text); font-weight: 600; }
.hist-row-ct   { color: var(--text-dim); }
.hist-row-sep  { color: var(--text-faint); }
.hist-row-stats {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-family: var(--font-body); font-size: var(--fs-xs);
  letter-spacing: 0.04em;
}
.hist-row-vs   { color: var(--text-faint); padding: 0 2px; font-family: var(--font-mono); }
.hist-row-loss { font-family: var(--font-mono); color: var(--text-dim); }
.hist-row-dice  { color: var(--text-dim); }
.hist-row-mildec { color: var(--text-dim); }
.loss-kia { color: var(--red); font-weight: 700; }
.loss-hp  { color: var(--orange); }
.loss-none { color: var(--text-faint); }
.hist-row-delete {
  background: none; border: none;
  font-size: 22px; line-height: 1;
  color: var(--text-faint);
  cursor: pointer;
  padding: 4px 8px;
  transition: color 120ms ease;
}
.hist-row-delete:hover { color: var(--red); }

/* ─── Detail (expanded) ─── */
.hist-row-detail {
  display: none;
  padding: 0 14px 14px;
  border-top: 1px dashed var(--line);
}
.hist-row.is-expanded .hist-row-detail { display: block; }

.hist-section { margin-top: 12px; }
.hist-section-label {
  font-family: var(--font-body); font-size: var(--fs-xs);
  letter-spacing: 0.16em; color: var(--text-faint);
  margin-bottom: 6px;
}
.hist-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.hist-chip {
  font-family: var(--font-body); font-size: var(--fs-xs);
  letter-spacing: 0.06em;
  padding: 3px 9px;
  background: var(--bg-1); border: 1px solid var(--line);
  color: var(--text-dim);
}
.hist-units { display: flex; flex-direction: column; gap: 4px; }
.hist-unit {
  display: grid;
  grid-template-columns: 56px 96px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 6px 10px;
  background: var(--bg-1);
  font-family: var(--font-body); font-size: var(--fs-sm);
}
.hist-unit.dead { opacity: 0.55; }
.hist-unit-dg { font-weight: 600; color: var(--text); letter-spacing: 0.04em; }
.hist-unit-nm { color: var(--text-dim); }
.hist-unit-hp { font-size: var(--fs-xs); color: var(--text-dim); }

.hist-rolls { display: flex; flex-direction: column; gap: 4px; }
.hist-roll {
  display: grid;
  grid-template-columns: 140px 60px 1fr auto;
  align-items: center; gap: 10px;
  padding: 5px 10px;
  background: var(--bg-1);
  font-family: var(--font-body); font-size: var(--fs-sm);
}
.hist-roll-kind { font-weight: 600; color: var(--text); letter-spacing: 0.06em; }
.hist-roll-cv   { color: var(--text-dim); font-size: var(--fs-xs); }
.hist-roll-dice { display: flex; gap: 4px; flex-wrap: wrap; }
.hist-roll-dice .d {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  background: var(--bg-3); border: 1px solid var(--line);
  font-family: var(--font-mono); font-size: 11px; color: var(--text-dim);
}
.hist-roll-dice .d.hit  { color: var(--green); border-color: var(--green); background: rgba(108,179,118,0.08); }
.hist-roll-dice .d.miss { color: var(--text-faint); }
.hist-roll-result { font-size: var(--fs-xs); color: var(--text-dim); }
