/* Keep the original three-column draft and portrait aspect ratio. */
.team-config {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}
.card-tactics {
  display: grid;
  gap: 2px;
  margin: 4px 0 1px;
  min-width: 0;
}
.card-tactics > span,
.card-tactics button {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font: inherit;
  font-size: 0.73rem;
  line-height: 1.35;
  padding: 2px 1px;
}
.card-tactics > span {
  color: #dec995;
}
.card-tactics button {
  color: #c2d5ec;
  background: #232d40;
  border: 1px solid #3b4c63;
  border-radius: 3px;
}
.confirmations {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-size: 0.82rem;
}
.prep .confirmations {
  margin: 12px 0;
}
dialog.tactics-window {
  width: min(1080px, calc(100vw - 20px));
  max-height: 94dvh;
  overflow: hidden;
}
dialog.tactics-window[open] {
  display: flex;
  flex-direction: column;
}
dialog.tactics-window .modal-head {
  flex: none;
  padding: 8px 16px;
}
dialog.tactics-window #dialog-body {
  min-height: 0;
  padding: 0;
  display: flex;
}
#tactic-editor {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: min(760px, calc(94dvh - 58px));
  min-height: 0;
  color: var(--ink);
}
#tactic-editor [hidden] {
  display: none !important;
}
#tactic-troops {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  margin: 2px 16px 5px;
  font-size: .85rem;
}
#tactic-troops label {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
#tactic-troops input { width: auto; }
.tactic-summary,
.tactic-footer,
.tactic-filter,
.tactic-groups,
#tactic-tools,
.preset-select {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}
.tactic-summary,
.tactic-footer {
  padding: 8px 16px;
  background: #151d2b;
}
.tactic-summary {
  min-height: 35px;
  border-bottom: 1px solid var(--line);
}
#tactic-meter {
  color: #e9cf91;
  font:
    700 1rem Consolas,
    monospace;
  white-space: nowrap;
}
#tactic-clock {
  margin-left: auto;
  font-size: 0.85rem;
  color: #f5d58d;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
#tactic-team {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  margin: 8px 16px 4px;
}
.tactic-unit {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: center;
  gap: 5px;
  background: #1f293b;
  border: 1px solid #344159;
  border-radius: 5px;
  padding: 6px 8px;
  min-width: 0;
}
.tactic-unit.selected {
  border-color: #81734f;
}
.tactic-unit b,
.tactic-unit > span,
.tactic-unit button {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.tactic-unit b {
  font-size: 0.9rem;
}
.tactic-unit b small {
  color: var(--muted);
  font-weight: 400;
}
.tactic-unit > span {
  text-align: right;
  font-size: 0.82rem;
  color: #d8c494;
}
.tactic-unit button {
  font-size: 0.79rem;
  padding: 3px 4px;
  text-align: left;
  background: #151d29;
  line-height: 1.4;
}
.tactic-unit button small {
  font: inherit;
  font-size: 0.72rem;
  color: #9ca9bc;
  padding-right: 4px;
}
.tactic-unit .current {
  border-color: #d9bc7c;
  color: #f7dda3;
  background: #3b352c;
}
.tactic-unit.vacant {
  opacity: 0.66;
}
.tactic-unit.vacant span {
  color: var(--muted);
}
#tactic-tools,
.tactic-filter,
.tactic-groups,
.preset-select {
  margin: 5px 16px;
  gap: 6px;
}
#tactic-tools button,
.tactic-groups button {
  padding: 4px 9px;
  font-size: 0.79rem;
}
#tactic-tools label,
.tactic-filter label,
.preset-select {
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  font-size: 0.8rem;
}
#tactic-tools select,
.tactic-filter select,
.preset-select select {
  padding: 4px 6px;
  height: 30px;
  font-size: 0.81rem;
  width: auto;
}
.tactic-filter input[type='search'] {
  min-width: 0;
  flex: 1;
  padding: 7px 9px;
}
.tactic-filter input[type='checkbox'] {
  height: 15px;
  width: 15px;
  margin: 0;
  accent-color: #bd9b60;
}
.tactic-groups {
  gap: 4px;
}
.tactic-groups button[aria-pressed='true'] {
  background: #354156;
  border-color: #a38b62;
  color: #ffe0a2;
}
.tactic-groups button[data-do='history'] {
  margin-left: auto;
}
#tactic-source {
  font-size: 0.73rem;
  color: var(--muted);
  padding: 0 16px;
}
#tactic-source:empty {
  display: none;
}
#tactic-scroll,
#tactic-history {
  flex: 1;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}
.tactic-grid {
  padding: 6px 16px 10px;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  grid-auto-rows: minmax(60px, max-content);
  align-content: start;
  gap: 6px;
}
.tactic-grid > .empty {
  grid-column: 1/-1;
}
.tactic-footer {
  justify-content: space-between;
  border-top: 1px solid var(--line);
}
#tactic-selection {
  font-size: 0.84rem;
  color: #c4ccda;
}
.tactic-footer .primary {
  padding: 7px 16px;
}
#tactic-details {
  position: absolute;
  z-index: 3;
  right: 16px;
  bottom: 49px;
  max-height: 62%;
  width: min(325px, calc(100% - 32px));
  overflow: auto;
  padding: 12px;
  background: #252e40;
  border: 1px solid #9e8964;
  border-radius: 7px;
  box-shadow: 0 8px 30px #0009;
  font-size: 0.88rem;
}
.tactic-detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.tactic-detail-head button {
  border: 0;
  background: none;
  font-size: 1.2rem;
  padding: 0 5px;
}
#tactic-details p {
  margin: 6px 0;
}
#tactic-details dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 3px 10px;
  margin: 6px 0;
}
#tactic-details dt,
#tactic-details small {
  color: var(--muted);
}
#tactic-details dd {
  margin: 0;
}
#tactic-details > button {
  display: block;
  margin-top: 8px;
}
#tactic-hover {
  position: fixed;
  z-index: 5;
  pointer-events: none;
  white-space: pre-line;
  max-width: min(340px, 70vw);
  padding: 9px 12px;
  color: #ece6d7;
  background: #17202d;
  border: 1px solid #9b875e;
  border-radius: 6px;
  box-shadow: 0 5px 20px #0008;
  font-size: 0.81rem;
  line-height: 1.5;
}
#tactic-history,
.usage-round {
  padding: 5px 16px;
}
.usage-round {
  border-bottom: 1px solid var(--line);
}
.usage-round h3 {
  font-size: 0.92rem;
  margin: 5px 0;
}
.usage-round > div {
  display: flex;
  gap: 8px;
  align-items: baseline;
  font-size: 0.82rem;
}
.usage-round b {
  white-space: nowrap;
}
.usage-round p {
  margin: 4px 0;
}
.personal #tactic-team {
  grid-template-columns: minmax(0, 1fr);
}
@media (min-width: 1300px) {
  .tactic-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}
@media (min-width: 740px) and (max-width: 979px) {
  .tactic-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
@media (max-width: 739px) {
  dialog.tactics-window {
    width: calc(100vw - 8px);
    max-width: calc(100vw - 8px);
    max-height: 98dvh;
  }
  #tactic-editor {
    height: calc(98dvh - 50px);
  }
  .tactic-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 5px 8px;
    gap: 5px;
  }
  .tactic-summary,
  .tactic-footer {
    padding: 6px 8px;
  }
  #tactic-team,
  .tactic-filter,
  .tactic-groups,
  #tactic-tools,
  .preset-select {
    margin: 4px 8px;
  }
  #tactic-team {
    gap: 4px;
  }
  .tactic-unit {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    padding: 4px;
    min-width: 0;
  }
  .tactic-unit > span {
    text-align: left;
    font-size: 0.72rem;
  }
  .tactic-unit b,
  .tactic-unit button {
    font-size: 0.77rem;
  }
  .tactic-unit button {
    padding: 3px 2px;
  }
  .tactic-unit b small {
    font-size: 0.65rem;
  }
  #tactic-tools,
  .tactic-groups {
    gap: 3px;
    flex-wrap: wrap;
  }
  #tactic-tools button,
  .tactic-groups button {
    font-size: 0.72rem;
    padding: 4px 5px;
  }
  .tactic-filter {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 4px;
  }
  .tactic-filter input[type='search'] {
    grid-column: 1/-1;
    width: 100%;
    height: 30px;
  }
  .tactic-filter select {
    width: 100%;
    min-width: 0;
  }
  .tactic-filter label,
  .confirmations {
    font-size: 0.73rem;
    gap: 4px;
  }
  #tactic-clock {
    font-size: 0.72rem;
  }
  .card-tactics > span,
  .card-tactics button {
    font-size: 0.64rem;
    line-height: 1.3;
    padding: 2px 0;
  }
  .team-config {
    gap: 2px;
  }
  .personal .tactic-unit {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}
@media (max-height: 540px) and (orientation: landscape) {
  dialog.tactics-window .modal-head {
    padding: 2px 10px;
  }
  #tactic-editor {
    height: calc(96dvh - 34px);
  }
  #tactic-team,
  .tactic-filter,
  .tactic-groups,
  #tactic-tools {
    margin-top: 2px;
    margin-bottom: 2px;
  }
  .tactic-summary,
  .tactic-footer {
    padding: 3px 12px;
    min-height: 25px;
  }
  .tactic-filter {
    display: flex;
  }
  .tactic-unit {
    display: grid;
  }
}

/* All lineup entry points use the same slots and troop controls. */
.card-tactics small { color:#b6c7d8; font-size:.7rem; line-height:1.35; text-align:center; overflow-wrap:anywhere; }
.card-tactics .card-traits { color:#9aa8b8; }
.general-detail + .card-tactics, .detail + .card-tactics, #dialog-body > .card-tactics {
  grid-template-columns:repeat(2,minmax(0,1fr)); gap:6px; margin:10px 0;
}
#dialog-body > .card-tactics > span, #modal-body > .card-tactics > span { grid-column:1/-1; }
#tactic-editor { background:#151d2b; }
#tactic-editor button, .formation-troops button { cursor:pointer; font-family:inherit; }
#tactic-editor button:disabled { cursor:default; }
#tactic-selection { font-weight:700; color:#f4dfaf; white-space:nowrap; }
#tactic-search {
  width:min(360px,42%); margin:0 auto 0 8px; min-width:0; border:1px solid #485875;
  background:#101825; border-radius:5px; color:#e9eef7; padding:7px 12px; font-size:.88rem;
}
#tactic-clock { margin-left:0; color:#f3d693; }
.tactic-summary { background:#1d283a; gap:8px; }
#tactic-team { margin-top:9px; }
.tactic-unit[data-card-hero] { cursor:pointer; }
.tactic-unit.selected { border-color:#dcbb77; box-shadow:inset 0 0 0 1px #dcbb77; }
.tactic-unit button { border:1px solid #40506a; border-radius:4px; color:#d7e1ed; }
.tactic-unit button[aria-pressed=true] { color:#ffe6b5; background:#3b352c; border-color:#baa16b; }
#tactic-tools { flex-wrap:wrap; }
.move-unit { display:flex; margin-left:auto; gap:2px; }
#tactic-troops, .formation-troops {
  display:flex; flex-wrap:wrap; gap:5px 16px; align-items:center;
  padding:7px 9px; border:1px solid #37445a; border-radius:5px; background:#192333;
}
.troop-row,.filter-row { display:flex; align-items:center; gap:4px; flex-wrap:wrap; }
.troop-row b,.filter-row b { font-size:.73rem; color:#9faec1; margin-right:4px; }
#tactic-editor .troop-row button, .formation-troops button, .filter-row button,
#tactic-tools button,.tactic-groups button {
  background:#222e41; border:1px solid #3b4a60; border-radius:4px; color:#d2dce9;
  font-size:.77rem; line-height:1.4; padding:3px 8px;
}
#tactic-editor button[aria-pressed=true], .formation-troops button[aria-pressed=true] { color:#ffe3a8; background:#39342b; border-color:#9e885c; }
#tactic-tools button:disabled,.troop-row button:disabled { opacity:.6; }
.troop-effects { font-size:.72rem; color:#bdc9d7; }
.troop-effects summary { cursor:pointer; color:#d3bd91; }
.tactic-facets { display:grid; gap:5px; padding:6px 16px; background:#182231; border-block:1px solid #2d394c; }
.filter-row button { padding:2px 10px; border-color:transparent; background:transparent; }
.available-toggle { display:flex; align-items:center; gap:4px; font-size:.77rem; margin-left:auto; color:#cad5e1; }
.available-toggle input { width:auto; accent-color:#d4b77d; }
.tactic-groups button[data-do=history] { margin-left:0; }
.tactic-footer { min-height:45px; color:#bcc8d8; font-size:.8rem; }
.tactic-footer > div { display:flex; align-items:center; gap:7px; flex-wrap:wrap; }
#modal.tactics-window #modal-body { flex:1; display:flex; flex-direction:column; padding:0; min-height:0; overflow:hidden; }
#modal.tactics-window .dialog-head { padding:8px 16px; }
#modal.tactics-window #modal-eyebrow:empty { display:none; }
#practice-notice:not([hidden]) { margin:0; padding:5px 12px; color:#f6d792; }
#modal .primary, .tactic-footer .primary { background:#d9bc80; color:#201e18; border:0; border-radius:5px; font-weight:700; }
@media(max-width:739px) {
  #tactic-troops { margin:2px 8px 4px; gap:4px 8px; padding:4px; }
  .tactic-facets { padding:4px 8px; gap:2px; }
  .filter-row, .troop-row { gap:2px; }
  .filter-row button,#tactic-editor .troop-row button { padding:3px 5px; font-size:.72rem; }
  #tactic-tools { margin-block:2px; }
  #tactic-search { width:auto; flex:1; margin:0; padding:6px; font-size:.78rem; }
  #tactic-selection { font-size:.75rem; }
  .available-toggle { font-size:.71rem; }
  .tactic-footer > div { gap:3px; }
  .tactic-footer .confirmations { flex-wrap:wrap; }
  .card-tactics small { font-size:.62rem; }
}

#tactic-adjust { display:none; }
#tactic-settings { flex:none; }
.point-controls { display:grid; gap:3px; width:100%; max-width:32rem; color:#dbe4ef; }
.point-row,.point-heading { display:grid; align-items:center; gap:6px; }
.point-row { grid-template-columns:minmax(3em,1fr) 3em 44px 44px minmax(54px,auto); border-top:1px solid #344159; }
.point-row b,.point-heading span { color:#f4dba4; font-variant-numeric:tabular-nums; }
.point-heading { grid-template-columns:auto 1fr auto; }
.point-controls button,.tactic-empty button,.filter-empty button { min-height:44px; padding:3px 8px; border:1px solid #475871; border-radius:4px; color:#dbe4ef; background:#223148; touch-action:manipulation; }
.point-controls button:disabled { opacity:.45; }
.filter-empty { display:none; }
#tactic-editor .filter-row button { min-height:32px; min-width:36px; }
.tactic-empty { grid-column:1/-1; }
#preset-chooser { position:relative; margin:4px 16px 0; font-size:.84rem; }
#preset-chooser summary { cursor:pointer; width:fit-content; color:#e4c98d; }
.preset-popup { position:absolute; z-index:4; top:100%; left:0; width:min(420px,100%); padding:8px; background:#1e2a3d; border:1px solid #54647b; border-radius:5px; }
#preset-search { width:100%; padding:6px; background:#111a29; border:1px solid #44506a; color:#e6eaf3; }
#preset-list { max-height:min(35dvh,270px); overflow:auto; display:grid; grid-template-columns:1fr 1fr; gap:3px; margin-top:5px; }
#preset-list button { text-align:left; padding:4px 6px; background:#273348; color:#e3e8f1; border:0; }
#preset-list small { display:block; font-size:.69rem; color:#b9c6d7; }
@media(max-width:739px) {
  .tactic-info { min-width:30px; min-height:30px; text-align:center; }
}
@media(max-height:570px) {
  #tactic-adjust { display:block; align-self:flex-start; margin:2px 10px; background:#29354a; color:#e7d3a9; border:1px solid #495672; font-size:.77rem; padding:3px 9px; }
  .settings-expanded #tactic-adjust { position:relative; z-index:3; }
  #tactic-settings { display:none; }
  .settings-expanded #tactic-settings { display:block; max-height:25dvh; overflow:auto; flex-shrink:1; background:#1b2638; border-block:1px solid #78879a; }
  #tactic-editor { height:calc(96dvh - 44px); }
}
