.ew-troop-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 12px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  direction: rtl;
  background: rgba(2, 6, 18, 0.84);
  backdrop-filter: blur(8px);
  font-family: inherit;
}

.ew-troop-sheet {
  width: min(100%, 520px);
  max-height: min(88vh, 760px);
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid rgba(245, 197, 66, 0.32);
  border-radius: 24px;
  padding: 18px;
  color: #f8fafc;
  background: linear-gradient(155deg, #151e34 0%, #0a0e1a 72%);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.7), 0 0 30px rgba(245, 197, 66, 0.1);
}

.ew-troop-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.ew-troop-head span,
.ew-troop-head strong {
  display: block;
}

.ew-troop-head span {
  color: #f5c542;
  font-size: 17px;
  font-weight: 900;
}

.ew-troop-head strong {
  margin-top: 4px;
  color: #cbd5e1;
  font-size: 12px;
}

.ew-troop-head > button {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 11px;
  color: #94a3b8;
  background: #1a2440;
}

.ew-troop-toolbar {
  display: flex;
  gap: 8px;
  margin: 15px 0 10px;
}

.ew-troop-toolbar button {
  flex: 1;
  border: 1px solid rgba(245, 197, 66, 0.2);
  border-radius: 10px;
  padding: 8px 10px;
  color: #f5c542;
  background: rgba(245, 197, 66, 0.08);
  font-size: 12px;
  font-weight: 700;
}

.ew-troop-list {
  display: grid;
  gap: 9px;
}

.ew-troop-row {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 15px;
  padding: 11px;
  background: rgba(18, 26, 46, 0.88);
}

.ew-troop-identity {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ew-troop-identity strong,
.ew-troop-identity small {
  display: block;
}

.ew-troop-identity strong {
  font-size: 13px;
}

.ew-troop-identity small {
  margin-top: 2px;
  color: #94a3b8;
  font-size: 10px;
}

.ew-troop-emoji {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 12px;
  background: #0a0e1a;
  font-size: 21px;
}

.ew-troop-controls {
  display: grid;
  grid-template-columns: 34px minmax(70px, 1fr) 34px 48px;
  gap: 6px;
  margin-top: 9px;
}

.ew-troop-controls button,
.ew-troop-controls input {
  height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 9px;
  color: #f8fafc;
  background: #0a0e1a;
  text-align: center;
  font: inherit;
  font-size: 13px;
}

.ew-troop-controls button {
  color: #f5c542;
  font-size: 18px;
  font-weight: 900;
}

.ew-troop-controls .ew-troop-max {
  font-size: 10px;
}

.ew-troop-controls input:focus {
  border-color: rgba(245, 197, 66, 0.7);
  outline: none;
}

.ew-troop-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.ew-troop-summary > div {
  border: 1px solid rgba(245, 197, 66, 0.16);
  border-radius: 12px;
  padding: 10px;
  text-align: center;
  background: rgba(245, 197, 66, 0.06);
}

.ew-troop-summary small,
.ew-troop-summary strong {
  display: block;
}

.ew-troop-summary small {
  color: #94a3b8;
  font-size: 10px;
}

.ew-troop-summary strong {
  margin-top: 2px;
  color: #f5c542;
  font-size: 17px;
}

.ew-troop-note {
  margin: 10px 0 0;
  color: #94a3b8;
  font-size: 10px;
  line-height: 1.8;
}

.ew-troop-validation {
  min-height: 18px;
  margin: 3px 0;
  color: #fb7185;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}

.ew-troop-actions {
  display: grid;
  grid-template-columns: 0.7fr 1.3fr;
  gap: 8px;
}

.ew-troop-actions button,
.ew-troop-error button {
  min-height: 44px;
  border: 0;
  border-radius: 13px;
  color: #cbd5e1;
  background: #1a2440;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
}

.ew-troop-actions .ew-troop-confirm {
  color: #171006;
  background: linear-gradient(135deg, #f8d760, #c9971f);
}

.ew-troop-actions .ew-troop-confirm:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.ew-troop-loading,
.ew-troop-error {
  display: grid;
  min-height: 190px;
  place-items: center;
  align-content: center;
  gap: 12px;
  text-align: center;
}

.ew-troop-loading span,
.ew-troop-error p {
  margin: 0;
  color: #94a3b8;
  font-size: 12px;
}

.ew-troop-error button {
  min-width: 120px;
  padding: 0 20px;
}

.ew-troop-spinner {
  width: 34px;
  height: 34px;
  border: 3px solid rgba(245, 197, 66, 0.2);
  border-top-color: #f5c542;
  border-radius: 50%;
  animation: ew-troop-spin 0.8s linear infinite;
}

@keyframes ew-troop-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (min-width: 640px) {
  .ew-troop-modal {
    align-items: center;
  }

  .ew-troop-sheet {
    padding: 22px;
  }
}
