/* V1.132 — one professional command-state language across the whole turn. */
.battle-command-state {
  --battle-state-color: #9bdff3;
  --battle-state-glow: rgba(89, 193, 231, 0.24);
  width: min(760px, calc(100% - 20px));
  min-height: 64px;
  margin: clamp(8px, 1.6vh, 14px) auto 8px;
  padding: 10px 14px;
  display: grid;
  grid-template-columns: 36px minmax(150px, 0.72fr) minmax(220px, 1.28fr);
  grid-template-areas:
    "emblem copy detail"
    "progress progress progress";
  gap: 7px 12px;
  align-items: center;
  border: 1px solid color-mix(in srgb, var(--battle-state-color) 38%, rgba(255, 255, 255, 0.1));
  border-radius: 12px;
  color: #eefaff;
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--battle-state-color) 9%, transparent), transparent 42%),
    linear-gradient(180deg, rgba(13, 26, 42, 0.94), rgba(5, 12, 24, 0.96));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    inset 0 0 30px color-mix(in srgb, var(--battle-state-color) 6%, transparent),
    0 12px 26px rgba(0, 0, 0, 0.28),
    0 0 22px var(--battle-state-glow);
  isolation: isolate;
  overflow: hidden;
}

.battle-command-state[data-phase="ready"] {
  --battle-state-color: #83ecbd;
  --battle-state-glow: rgba(58, 219, 154, 0.2);
}

.battle-command-state:is([data-phase="targeting"], [data-phase="required"]) {
  --battle-state-color: #ffd277;
  --battle-state-glow: rgba(246, 190, 73, 0.24);
}

.battle-command-state[data-phase="submitting"] {
  --battle-state-color: #8bdcff;
  --battle-state-glow: rgba(77, 192, 255, 0.28);
}

.battle-command-state:is([data-phase="locked"], [data-phase="controlled"]) {
  --battle-state-color: #b9b5ff;
  --battle-state-glow: rgba(128, 113, 255, 0.22);
}

.battle-command-state:is([data-phase="settling"], [data-phase="complete"]) {
  --battle-state-color: #ffca62;
  --battle-state-glow: rgba(246, 171, 54, 0.3);
}

.battle-command-state-emblem {
  grid-area: emblem;
  position: relative;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--battle-state-color) 72%, transparent);
  border-radius: 9px;
  background: radial-gradient(circle, color-mix(in srgb, var(--battle-state-color) 24%, transparent), rgba(4, 12, 24, 0.72) 68%);
  box-shadow: inset 0 0 12px color-mix(in srgb, var(--battle-state-color) 18%, transparent), 0 0 13px var(--battle-state-glow);
  transform: rotate(45deg);
}

.battle-command-state-emblem::before {
  content: "";
  width: 9px;
  height: 9px;
  border: 2px solid var(--battle-state-color);
  border-radius: 50%;
  box-shadow: 0 0 9px var(--battle-state-color);
}

.battle-command-state[data-phase="submitting"] .battle-command-state-emblem::before {
  border-color: transparent var(--battle-state-color) var(--battle-state-color) transparent;
  animation: battle-command-emblem-spin 760ms linear infinite;
}

.battle-command-state-copy {
  grid-area: copy;
  min-width: 0;
  display: grid;
  gap: 2px;
}

.battle-command-state-copy small {
  color: color-mix(in srgb, var(--battle-state-color) 80%, #ffffff 20%);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.13em;
}

.battle-command-state-copy strong {
  overflow: hidden;
  color: #f6fcff;
  font-size: clamp(14px, 1.35vw, 17px);
  font-weight: 950;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-shadow: 0 0 13px var(--battle-state-glow);
}

.battle-command-state > em {
  grid-area: detail;
  min-width: 0;
  color: rgba(223, 238, 250, 0.78);
  font-size: 11px;
  font-style: normal;
  font-weight: 760;
  line-height: 1.35;
  text-align: right;
}

.battle-command-state-progress {
  grid-area: progress;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 5px;
}

.battle-command-state-progress > i {
  height: 3px;
  border-radius: 999px;
  background: rgba(177, 205, 225, 0.13);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.035);
  transition: background-color 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
}

.battle-command-state[data-stage="1"] .battle-command-state-progress > i:nth-child(-n + 1),
.battle-command-state[data-stage="2"] .battle-command-state-progress > i:nth-child(-n + 2),
.battle-command-state[data-stage="3"] .battle-command-state-progress > i:nth-child(-n + 3),
.battle-command-state[data-stage="4"] .battle-command-state-progress > i:nth-child(-n + 4),
.battle-command-state[data-stage="5"] .battle-command-state-progress > i:nth-child(-n + 5),
.battle-command-state[data-stage="6"] .battle-command-state-progress > i:nth-child(-n + 6) {
  background: var(--battle-state-color);
  box-shadow: 0 0 8px var(--battle-state-glow);
}

.battle-command-state-enter {
  animation: battle-command-state-enter 260ms cubic-bezier(0.2, 0.72, 0.24, 1);
}

@keyframes battle-command-state-enter {
  from { opacity: 0.62; filter: brightness(0.82); transform: translateY(3px); }
  to { opacity: 1; filter: none; transform: none; }
}

@keyframes battle-command-emblem-spin {
  to { transform: rotate(1turn); }
}

@media (max-width: 720px) {
  .battle-command-state {
    width: calc(100% - 12px);
    min-height: 58px;
    margin-block: 6px;
    padding: 8px 10px;
    grid-template-columns: 30px minmax(0, 1fr);
    grid-template-areas:
      "emblem copy"
      "detail detail"
      "progress progress";
    gap: 5px 9px;
  }

  .battle-command-state-emblem {
    width: 27px;
    height: 27px;
    border-radius: 7px;
  }

  .battle-command-state > em {
    overflow: hidden;
    font-size: 10px;
    text-align: left;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

@media (prefers-reduced-motion: reduce) {
  .battle-command-state,
  .battle-command-state-progress > i,
  .battle-command-state-emblem::before {
    animation: none !important;
    transition: none !important;
  }
}

@media (forced-colors: active) {
  .battle-command-state {
    border: 2px solid CanvasText;
    background: Canvas;
    color: CanvasText;
  }

  .battle-command-state-progress > i {
    border: 1px solid CanvasText;
  }

  .battle-command-state[data-stage] .battle-command-state-progress > i {
    background: Highlight;
  }
}
